matte
matte

Reputation: 97

Needed path variables for different conda virtual environments

I've had troubles in setting up a conda virtual environment specifically intended to collect Deep Learning packages. I read loads of tutorials, I also uninstalled and reinstalled Anaconda some times to make sure everything during the installation had been set properly.

I finally ended up with a virtual environment, say DLenv, in which jupyter notebook could not be launched (it simply did not run whatsoever. Browser used to open, but the jupyter home page did not load at all). After some researches I found out a possible solution in uninstalling pyzmq, installing it again and then installing again jupyter.

After launching the command

(DLenv) C:/Users/.../folder > jupyter notebook

the following message showed up:

Unable to create process using 'C:\Users\Matteo\Anaconda3\envs\DLenv\python.exe C:\Users\Matteo\Anaconda3\envs\DLenv\Scripts\jupyter-script.py notebook'

I somewhat felt the suspect that it was in some way due to the fact that the DLenv environment had few to do with the Anaconda installation step, when the user is asked whether include Anaconda in path variables or not. So I added both the paths of the object referred to in the above error to environment variables in my system but that still did not work. Finally I had the idea of copying the python.exe file referred to in the first part of the error in the second location mentioned, that is, in the directory dedicated to the new virtual environment.

Now it seems to work, in that from the DLenv jupyter notebook is lanched, kernel does not have connection issues.

My question then is: why on earth the python.exe object was required to be in the virtual environment folder and why it has not been moved there automatically during environment creation stage?

Shall I do the same iter every time a new environment is created?

Thanks in advance

Upvotes: 0

Views: 64

Answers (1)

merv
merv

Reputation: 76770

The proper way to interface with Jupyter and Conda envs is to only install the jupyter package in a single env, which if you are using Anaconda already is base. You also need to install nb_conda_kernels in that env. Then, for every other env that you want to use as a kernel you install ipykernel. Launch jupyter notebook from the env that has it (base), and the other envs will be available as kernels.

There should be no manual manipulation of your PATH environment variable since Conda v4.4. Conda has its own internal tooling for managing this, and messing with it can lead to unexpected behavior.

Upvotes: 1

Related Questions