Auto-select python from the activated environment
See original GitHub issueEnvironment data
- VS Code version: 1.51.1
- Extension version (available under the Extensions sidebar): (what is that? not finding)
- OS and version: Windows 10 1909 (18363.1198)
- Python version (& distribution if applicable, e.g. Anaconda): 3.7.8 (Anaconda)
- Type of virtual environment used (N/A | venv | virtualenv | conda | …): conda
- Relevant/affected Python packages and their versions: PySide2==5.15.2, sip==5.5.0
- Relevant/affected Python-related VS Code extensions and their versions: Anaconda Extension Pack==v1.0.1, Python==v2020.11.371526539, Qt for Python==v0.5.3
- Value of the
python.languageServer
setting: Jedi
[NOTE: If you suspect that your issue is related to the Microsoft Python Language Server (python.languageServer: 'Microsoft'
), please download our new language server Pylance from the VS Code marketplace to see if that fixes your issue]
Expected behaviour
well i expected it to import PySide2
, but it failed.
Actual behaviour
When running the python script with the automatically generated launch.json
Traceback (most recent call last):
File "e:\Python\myenv\src\main.py", line 16, in <module>
from draw import draw_window
File "e:\Python\myenv\src\draw.py", line 13, in <module>
from PySide2 import QtCore, QtGui, QtWidgets
ModuleNotFoundError: No module named 'PySide2'
Steps to reproduce:
[NOTE: Self-contained, minimal reproducing code samples are extremely helpful and will expedite addressing your issue]
-
Create a file (say,
main.py
) -
Input only one single line:
import PySide2
-
Save and change to the virtual env, run with the debugger provided by Python extension
-
You’ll see the
ModuleNotFoundError: No module named 'PySide2'
-
Running
python main.py
doesn’t raise this error -
Running
import PySide2
in python interactivate mode doesn’t raise this error -
I’m pretty sure that I DID
pip install PySide2
in my virtual env, andpip show PySide2
DOESN’T raiseWARNING: Package(s) not found
, so i suspect it a problem has something to do with the extension.
Logs
I post the output of pip freeze
of my env here:
certifi==2020.12.5
packaging==20.7
pyparsing==2.4.7
PyQt5==5.15.2
PyQt5-sip==12.8.1
PySide2==5.15.2
pywin32==225
shiboken2==5.15.2
sip==5.5.0
toml==0.10.2
wincertstore==0.2
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:12 (6 by maintainers)
Top GitHub Comments
Yes. The extension should be able to select the python based on activated environment or CONDA_PREFIX.
We have marked this issue as “needs decision” to make sure we have a conversation about your idea. We plan to leave this feature request open for at least a month to see how many 👍 votes the opening comment gets to help us make our decision.
Closing in favor of https://github.com/microsoft/vscode-python/issues/18178