Open
Description
Type: Bug
Behaviour
Expected vs. Actual
When I activate a virtual environment I expect python to use packages from this virtual environment over globally installed packages.
If run the debugger with the vscode python extension on Ubuntu sys.path contains /usr/lib/python3/dist-packages in front of the venv packages. This causes global packages to be loaded.
If you add export PYTHONPATH=""
to .zshrc this is not added to sys.path during debug. But if you modify the PYTHONPATH eg to add a src
folder inside your launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Python Debugger: Current File with Arguments",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"env": {
"PYTHONPATH": "src"
}
}
]
}
it still shows up in sys.path
Steps to reproduce:
- Create venv
- Select venv in vscode
- Create launch.json file as above
- debug a python file and print sys.path
- Verify that /usr/lib/python3/dist-packages is in path before venv folders
Diagnostic data
- Python version (& distribution if applicable, e.g. Anaconda): 3.9.18
- Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Venv
- Value of the
python.languageServer
setting: Default
Output for Python
in the Output
panel (View
→Output
, change the drop-down the upper-right of the Output
panel to Python
)
XXX
User Settings
languageServer: "Pylance"
terminal
• activateEnvironment: false
Extension version: 2024.0.1
VS Code version: Code 1.86.2 (903b1e9d8990623e3d7da1df3d33db3e42d80eda, 2024-02-13T19:41:37.860Z)
OS version: Linux x64 6.2.0-39-generic
Modes:
A/B Experiments
vsliv368cf:30146710
vspor879:30202332
vspor708:30202333
vspor363:30204092
vscoreces:30445986
vscod805cf:30301675
binariesv615:30325510
vsaa593cf:30376535
py29gd2263:30899288
c4g48928:30535728
azure-dev_surveyone:30548225
vscrpc:30673769
962ge761:30959799
pythongtdpath:30769146
welcomedialog:30910333
pythonidxpt:30866567
pythonnoceb:30805159
asynctok:30898717
pythontestfixt:30902429
pythonregdiag2:30936856
pyreplss1:30897532
pythonmypyd1:30879173
pythoncet0:30885854
pythontbext0:30879054
dsvsc016:30899300
dsvsc017:30899301
dsvsc018:30899302
edj9j583:30958191
fegfb526:30961430
7j2b6412:30964151
ccp1r6:30958156
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment