Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS Code Python Interactive Window Cannot find Conda Env

Everytime I try to execute my python code to the Python Interactive Window I get the below error...

Executing code failed : Error: Activating Python 3.7.3 64-bit ('base': conda) to run Jupyter failed with Error: 
Command failed: "H:/My Documents/Continuum/anaconda3/Scripts/activate" && conda activate base && 
echo 'e8b39361-0157-4923-80e1-22d70d46dee6' && python 
c:/Users/paul.victor/.vscode/extensions/ms-python.python-2019.11.50794/pythonFiles/printEnvVariables.py python: 
can't open file 'H:\My': [Errno 2] No such file or directory .

I have a feeling I'm supposed to try to remap my vscode/python extension that is installed in the C drive to where my anaconda is saved which is the H drive, but I'm not sure how to do that in the vs code settings. Any help would be greatly appreciated.

Follow Up to Original

user8408080 was correct that removing the space did help. I also modified the path to the anaconda environment to my companies drive nomenclature,

instead of H: it used something like \\company\user...

Now that I fixed that it's kicking out another error saying the system cannot find the path specified even though the path is correct.

Executing code failed : Error: Activating Python 3.7.3 64-bit ('base': conda) to run 
Jupyter failed with Error: Command failed:\\apachecorp.com\files\SanAntonio\Home\Paul.Victor\Documents\Continuum\anaconda3\Scripts\activate base && 
echo 'e8b39361-0157-4923-80e1-22d70d46dee6' && 
python c:/Users/paul.victor/.vscode/extensions/ms-python.python-2019.11.50794/pythonFiles/printEnvVariables.py The system cannot find the path specified. .
like image 476
PVic Avatar asked Jan 25 '23 11:01

PVic


1 Answers

Looks like your Anaconda in PATH and Python Path in VSCode are pointing in different places.

First, check under system variables that your Anaconda is mapped to PATH based off where it is installed.

1- Click Start Menu Windows logo, type "path" click on "edit the system environment labels"

2- Under PATH for User Variables, if VSCode installed correctly to it, you will see the location of the bin file. Add to the PATH variable if it is not there. Mine looked like C:\Users\hSin\AppData\Local\Programs\Microsoft VS Code\bin

3 - Under PATH for System Variables, if Anaconda installed correctly to it, you will see the associated paths. There are multiple files/directories that should be a part here. Verify existence before adding as some of these are specific to when Anaconda installed and what settings you chose.

C:\ProgramData\Anaconda3; C:\ProgramData\Anaconda3\Library\mingw-w64; C:\ProgramData\Anaconda3\Library\usr\bin; C:\ProgramData\Anaconda3\Library\bin; C:\ProgramData\Anaconda3\Scripts

4 - Once all Path setups of Anaconda are confirmed, you should be able to call python from the terminal regardless of directory terminal is in. If not, your VSCode doesn't have the correct interpreter mapped. Go to VSCode -> File -> Preferences -> Settings and then search as below to find the Python:Python Path setting. It should map to the root installation of your Anaconda. Standard is C:\ProgramData\Anaconda3

VSCode Settings

5 - If still not working, your installations went to haywire and will require a reinstall of both applications. Install Anaconda first, make sure to check off the box to add to PATH, this is not default checked in the base installation. Then install VSCode, and set as default text editor. The Anaconda extension pack should come up as recommended, which will tie the two softwares together seamlessly if installed after Anaconda.

like image 160
hSin Avatar answered Jan 29 '23 12:01

hSin