I have several packages being imported perfectly in my Python 3.5. But not in my Jupyter Notebook... When i try to Import those packages in Jupyter i get and error of module not found. Is there a way to make Jupyter load my Python 3.5 as a kernel... or something similar. I'm working in a virtual environment. Already tried to reinstall the packages again in my virtual env But no success.
Asked
Active
Viewed 596 times
2 Answers
1
Try to install the packages inside a jupyter notebook cell like this:
!pip install package
So you are sure that the packages are installed in jupyter's environment

Billy Bonaros
- 1,671
- 11
- 18
-
1Tks for the suggestion ! But did not work ... It seems there's something very wrong with my Jupyter Notebook .... I could not install any packages using this approach. Tried to use with a package cv2 for example ... and got an error ("Could not find a version thta satisfies the requirement cv2 ... " ... In fact even numpy will give me problems ... If i run !pip install numpy ... for example ... i get "Requirement already satisfied... numpy in ... (path to my site-packages...)". but if i try to import numpy i get "import error" (no module named numpy...). – DavidPRO Sep 09 '19 at 06:32
-
I think you should reinstall anaconda or reinstall Jupiter notebook. check this: https://stackoverflow.com/questions/33052232/how-to-uninstall-jupyter – Billy Bonaros Sep 09 '19 at 08:02
-
1Yes Billy... i think this is the best way to... but i also found another thing: my Jupyter Notebook Kernel is looking for the packages from: home/
/.local/lib/python3.5/site-packages And not from: /home/davidpro/.virtualenvs/lob/python3.5/site-packages So, what i did was copying my complete site-packages folder to this folder: /home/davidpro/.local/lib/python3.5/site-packages and guess what … everything is working fine now in my Jupyter Notebook… well, everything sounds misterious for Linux Newbies like me ;-/ Again, thanks for your prompt help ! – DavidPRO Sep 09 '19 at 13:57
0
If you install the ipython kernel form inside the virtualenv, you can guarantee that the packages are imported to the jupyter if they are imported to this env. Also, if you use this approach, you do not need to activate the virtualenv every time you run the jupyter, because jupyter does it automatically.
$ python -m venv projectname
$ source projectname/bin/activate
(venv) $ pip install ipykernel
(venv) $ ipython kernel install --user --name=projectname
(venv) $ pip install {package needed to install}
-
Thanks for your reply Paulo. Could not run this because it claims that i don't have a module "venv" and if i try to install it i get Error: Could not find a version that satisfies the requirement venv..." ... and yes i get iPython – DavidPRO Sep 09 '19 at 06:37