-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Auto-select python from the activated environment #14918
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This is a known issue with activating
This will give you an activated environment, and the extension will not have to try and activate every time a terminal is created. |
hi @karthiknadig
urgh...... |
@1MLightyears Can you confirm that the selected python is same as the one where you have |
@karthiknadig Yes I'm pretty sure.
run
run without debugging it shows
but if i use
it ran without raising error! |
@1MLightyears Can you see that debugger is running
see if they match. I would expect the path to be something like "D:\Anaconda3\envs\clarisse\python.exe" since conda would be using the python.exe from the environment folder, not the root or base conda. |
@karthiknadig ok I know that the problem occurs in the command line, something is wrong when calling |
@1MLightyears Did the command I shared give a different path? Can you share your launch configuration for the debugger? Does the debugger config by chance set the pythonPath itself? I think the problem here is that the extension is not using the python.exe from activated environment (this might be a known issue with activated conda envs), but I don't know about this enough to confirm that. |
@karthiknadig yes you're right the extension isn't using the python.exe from the activated env, but the python.exe of the
does give |
@1MLightyears In your settings do you have If this does not work. Then please share the python extensions logs from Output > Python tab: |
@karthiknadig thanks, I cleaned |
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 #18178 |
Environment data
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
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 errorRunning
import PySide2
in python interactivate mode doesn't raise this errorI'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:The text was updated successfully, but these errors were encountered: