Conda environment Python is not used when starting VS Code from the terminal
See original GitHub issueVS Code version
1.62.0
Extension version
2021.11
OS type
macOS
OS version
11.6.1
Python distribution
Anaconda
Python version
3.9.6
Language server
Pylance
Expected behaviour
When I start VS Code from the macOS terminal using the code
command, I expect the integrated VS Code terminal to use the default conda environment. For example, when I open a folder from within VS Code (using File -> Open… from the menu), it opens the selected folder of Python files. I select a Python file to edit it and VS Code selects my default conda environment which is named base
. When I open the integrated VS Code terminal, it uses the base
conda environment and the associated Python. A screen capture of this process is shown below.
Actual behaviour
When I start VS Code from the macOS terminal using the code
command, the integrated VS Code terminal does not use the default conda environment’s Python. The integrated terminal uses the system Python and packages.
Steps to reproduce
From within the Mac terminal, I cd
to the folder containing the Python files. From within the directory, I open VS Code using the code .
terminal command. I select a Python file to edit and VS Code selects my default conda environment which is named base
. When I open the integrated VS Code terminal, it says I’m using the base
conda environment. However, the integrated VS Code terminal is not using the conda environment Python and packages. A screen capture of this is shown below.
Logs
No response
Code of Conduct
- I agree to follow this project’s Code of Conduct
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:8 (5 by maintainers)
Top GitHub Comments
@karthiknadig Sorry, but I think you have misunderstood him. He does not mean after he has selected a python interpreter in the system terminal then enter into the VSCode, the python interpreter activated in the system terminal should be inherited by the VSCode.
What has occurred is, he entered into the VSCode through the system terminal with the command of
code .
, no matter what environment has activated in the system terminal, the VSCode can not select theconda base
environment, even the bottom-left prompted he has selected theconda base
environment, even he select the python interpreter manually, even he activate the environment manually, even he create a new terminal, even he has opened the folder and selected theconda base
in the past and reopen it again, nothing works. He just can not get theconda base
environment when he entered into VSCode throughcode .
command.What a weird thing, just beyond my imagination. This is the link on StackOverflow
Closing this in favor of https://github.com/microsoft/vscode-python/issues/11039