1

Packages imported in my conda environment are not available in Jupyter notebook started from that location.

I'm not sure if my steps are right, or am I missing anything

  1. Creaed a folder structure for my work, and cd into my folder
  2. I created conda environment with the list of packages I want conda create -n practice1env scipy opencv
  3. Activated the environment source activate practice1env
  4. Cloned my GitHub repo git clone https://xxx Note that this contains jupyter notebooks
  5. opened a notebook file from my clone, and trying to edit it

When I work with numpy functions, it doesn't give me any trouble. But when i'm trying to import cv2 it says

ModuleNotFoundError: No Module named 'cv2'

One thing to note here is that - when i executed some commands, I got to know that the conda environments are in folder /anaconda/envs/practice1env where as my working directory (where i cloned my git repo) is a different folder. Assuming this might be the issue, i even cloned my repo in the same anaconda env folder, but still, the issue remains the same.

Whereas when i type command import cv2 in the terminal where i created conda env, it is importing fine. But not in the notebook started from a folder either within it or a diff folder

Ravi
  • 561
  • 2
  • 7
  • 19
  • You need to install at least the Jupyter Notebook kernel into your environment, in addition to the packages you want to use, and then you have to tell your notebook to use that kernel. `conda install -n practice1env ipykernel` should do it for installing, and the kernel selection happens in the Notebook. – darthbith Feb 19 '18 at 10:14
  • Thankyou, I'll try and let you know – Ravi Feb 19 '18 at 21:08

0 Answers0