I created a virtual environment with venv.
venv --python=/workspace/dev/python3.9 /var_path/var_virtual_env
In Visual Studio Code(portable version -Linux) I have set:
"python.venvPath": "/var_path/var_virtual_env",
"python.formatting.provider": "black"
The environment is seen in VSCode:
Code with python built-ins works without a problem.
From VS Code terminal with virtual environment activated using pip
I installed different packages and I expected the packages to be imported in the virtual environment, but instead seems that they are installed in the/home/user_name/local/lib/python3.6
.
Also I noticed that the configurations likepylint.d
etc are at same location in "local". The pylint was set thru VSCode.
To fix it I installed the packages in the environment outside VSCode, but the editor doesn't sees them. Example httpx
:
But they are in the environment, pip freeze output:
How can I fix this ?
Visual Studio Code™ portable app made with Portapps. A source code editor developed by Microsoft for Windows, Linux and macOS.
Select and activate an environment# To select a specific environment, use the Python: Select Interpreter command from the Command Palette (Ctrl+Shift+P).
Visual Studio Code supports Portable mode. This mode enables all data created and maintained by VS Code to live near itself, so it can be moved around across environments.
Another option for Linux development with VS Code is to use a Windows machine with the Windows Subsystem for Linux (WSL). Windows Subsystem for Linux. With WSL, you can install and run Linux distributions on Windows. This enables you to develop and test your source code on Linux while still working locally on a Windows machine.
Update Portable VS Code # On Windows and Linux, you can update VS Code by copying the data folder over to a more recent version of VS Code. On macOS, automatic updates should work as always, no extra work needed. Migrate to Portable mode #
This mode enables all data created and maintained by VS Code to live near itself, so it can be moved around across environments. This mode also provides a way to set the installation folder location for VS Code extensions, useful for corporate environments that prevent extensions from being installed in the Windows AppData folder.
In a terminal where the scarlette environment is activated, copy the output of which python
.
Set in settings.json
the following line:
{
"python.pythonPath": "paste_the_output_here"
....
}
I don't know if it will work in your case but that did the trick for me several times.
Click on:
And then choose python from venv.
Let know what happened.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With