1

I have made two new environments using conda and installed different dependencies in both environment. After activating one environment and opening jupyter notebook in that environment , I tried to import dependencies that I have installed for that environment but it showed me an error that this module is not present, after this I installed a jupyter notebook separately in that environment using :

pip install jupyter notebook

and error removed this time in that jupyter notebook. Also when I imported matplotlib in base environment it was imported but in new env it was showing no module error. Does it mean that whenever I have more than one environment , I have to install new jupyter notebook in every environment ? I don't want to use other environment dependencies in current environment but all i am asking is why i am unable to import package in jupyter notebook even though i have installed them in this environment.

Please help me out for this issue. I have wasted my 10 to 15 days understanding this but I didn't find anything.

GKS
  • 35
  • 5
  • Possible duplicate of [Link Conda environment with Jupyter Notebook](https://stackoverflow.com/questions/37433363/link-conda-environment-with-jupyter-notebook) – Stop harming Monica Aug 28 '18 at 09:19
  • this link doesn't solve my problem. – GKS Aug 28 '18 at 11:49
  • kindly specify twi things,.........1.windows or linux ? 2. how are you opening your jupyter notebook – Inder Aug 28 '18 at 11:52
  • @HiteshAggarwal You need to use a kernel based on the correct environment. Currently you are not doing that, otherwise you could import any packages installed in said environment. – Stop harming Monica Aug 28 '18 at 12:07

1 Answers1

2

Please do the following steps:

source activate [your_env_name]

conda install ipykernel

ipython kernel install --name [your_env_name]

Once this is done, launch your python code from your Jupyter Notebook

Select Kernel -> Change Kernel -> [your_env_name]

  • This works in Linux but not in Windows. I've just met this issue while I was trying to use two different kernels. When I launched `jupyter notebook` from one conda environment and switched to the other kernel I found `import numpy` that emits lots of errors. A simple proof would be like the followings. Compare the results from `(base) ~ $ miniconda3/envs/test-env/bin/python -c "import numpy"` and `(base) C:\Users\USER\Miniconda3\envs\test-env\python.exe -c "import numpy"`. – David Jung Dec 11 '19 at 05:09