I have a virtualenvwrapper-wrapped virtualenv. Let's call it test. Jupyter is installed through both my global pip and the virtualenv's pip.
$ which python
/usr/bin/python
$ which pip
/usr/local/bin/pip
$ which jupyter
/usr/local/bin/jupyter
$ workon test
(test)$ which python
/home/keon/.virtualenvs/test/bin/python
(test)$ which pip
/home/keon/.virtualenvs/test/bin/pip
(test)$ which jupyter
/home/keon/.virtualenvs/test/bin/jupyter
Now, I have package A installed through /usr/local/bin/pip and package B installed through /home/keon/.virtualenvs/test/bin/pip. (astropy and emcee resp., but I don't believe it matters)
I launch jupyter notebook (in a shell in the test virtualenv). I then run this code in a cell:
import astropy
import emcee
: And get the following error
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-12-43214a4612e2> in <module>()
1 import astropy
----> 2 import emcee
ImportError: No module named 'emcee'
In a cell, I use the ! shell commands:
!which python
!which pip
!which jupyter
!echo "Pip freeze below:\n---------------------"
!pip freeze
The output is
/home/keon/.virtualenvs/ph20/bin/python
/usr/local/bin/pip
/usr/local/bin/jupyter
Pip freeze below:
---------------------
[snip]
astropy==3.0.3
So my python is the virtualenv one but it seems to be using the global jupyter and pip.
This problem only seems to exist in one of my virtualenvs. If I use a different one, running the same cell described earlier the output is as expected:
/home/keon/.virtualenvs/test2/bin/python
/home/keon/.virtualenvs/test2/bin/pip
/home/keon/.virtualenvs/test2/bin/jupyter