Reputation: 4514
I have a module installed in my Juyter notebook
!pip install gensim
Requirement already satisfied: gensim in /home/m.gawinecki/virtualenv/la-recoms/lib/python3.7/site-packages (3.8.2)
However, when I try to import it, it fails
import gensim
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-e70e92d32c6e> in <module>
----> 1 import gensim
ModuleNotFoundError: No module named 'gensim'
It looks like it has been installed properly:
!pip list | grep gensim
gensim 3.8.2
How can I fix it?
Upvotes: 20
Views: 29993
Reputation: 191
This has been answerd in this post:
don't use !
before pip command because it is executed as in command line, instead use the %
sign to execute inside the virtual evironment of the current ipython kernel.
Upvotes: 10
Reputation: 919
Add your virtual environment as Python kernel in this way (Make sure it's activated):
(venv)
$ ipython kernel install --name "local-venv-kernel" --user
Now, you can select the created kernel "local-venv-kernel" when you start Jupyter notebook or lab.
You could check the installed libraries using this code in a notebook cell:
!pip freeze
Upvotes: 16
Reputation: 3160
Things that could help:
Upvotes: 1