Python: Xray fails with "Please install a virtual environment" with venv activated
See original GitHub issueAfter connecting to my Xray instance successfully and initiating a scan I get an error that claims I don’t have a virtual environment installed. Full error is:
Please install and activate a virtual environment before running Xray scan. Then, install your Python project in that environment.
My virtual environment is named ‘venv’ and lives at the root of my project. I have it selected as my virtual environment per VSCode’s instructions and have pip installed all packages to that environment. Debug log from JFrog as follows:
[INFO - 3:56:52 PM] Starting slow scan
[INFO - 3:56:52 PM] Locating go.mod files in workspace "workspace".
[DEBUG - 3:56:53 PM] No go.mod files found in workspaces.
[INFO - 3:56:53 PM] Locating package json files in workspace "workspace".
[DEBUG - 3:56:53 PM] No package.json files found in workspaces.
[INFO - 3:56:53 PM] Locating python files in workspace "workspace".
[DEBUG - 3:56:53 PM] Detected python files in workspace workspace: [file:///project/directory/requirements.txt]
[INFO - 3:56:53 PM] Locating pom.xml files in workspace "workspace".
[DEBUG - 3:56:53 PM] No pom.xml files found in workspaces.
[INFO - 3:56:53 PM] Locating *.sln files in workspace "workspace".
[DEBUG - 3:56:53 PM] No *.sln files found in workspaces.
I thought I followed the instructions in the README correctly. Any thoughts on why this might be happening?
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (6 by maintainers)
Top Results From Across the Web
venv — Creation of virtual environments — Python 3.11.1 ...
When a virtual environment has been activated, the VIRTUAL_ENV environment variable is set to the path of the environment. Since explicitly activating a...
Read more >python - Can't "activate" virtualenv - Stack Overflow
Call the Python module venv and create a new virtual environment in the directory venv · Run the script to activate the virtual...
Read more >Install Python, pip, and the EB CLI on Windows
To install the AWS CLI with pip (Windows) · Press the Windows key, and then enter environment variables . · Choose Edit environment...
Read more >Installing and using virtualenv with Python 3
Virtualenv is only installed on DreamHost servers for Python 2. If you're working with Python 3, you must install virtualenv using pip3. pip3...
Read more >pandas pypi
How to Install Python Pandas on Windows and Linux? ... to distribute their software. python - Install pandas on Mac M1 Big Sur...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m having the same exact issue as @ducoterra as well. I’m running version 1.7.0 of the extension in VS Code 1.55.0 on MacOS 10.15.7. I have verified that the virtual environment is activated, that dependencies are installed, and that the virtual environment is selected in VS Code per the instructions on the extension’s detail page:
I also get a result of 0 when running checkVenv.py with the virtual environment activated and a 1 if it’s not activated. If there are log files, can you tell me where to find them so I can include them here?
Running checkVenv.py through a debugger, it seems that virtualenv_prefix is being set to None and venv_prefix is being set to ‘/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8’, which is not the project’s activated virtual environment. The correct virtual environment is returned by sys.prefix:
I’m wondering if there might be a bug in
isInVirtualEnv()
orgetPythonPath()
in pypiUtils.ts sinceisInVirtualEnv()
is obviously returning a false value given the following error message:Please install and activate a virtual environment before running Xray scan. Then, install your Python project in that environment.
@ducoterra @rderveloy @mlieberman85, JFrog VS-Code extension 1.8.5 is released! On this version we retrieve the Python executable path in a better way - see https://github.com/jfrog/jfrog-vscode-extension/pull/127. Feel free to upgrade - we’d appreciate your feedback on that.
@DrackThor - currently only Virtualenv is supported by the extension.