Issue
I think this question is probably closely related to another one I had, but I'm not sure what the best general-purpose answer is.
On my laptop, if I log into the IPython shell, I can execute
In [1]: import matplotlib
without error.
But if I try to do the same thing in a Jupyter notebook, I get the following error:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-2-82be63b7783c> in <module>()
----> 1 import matplotlib
ModuleNotFoundError: No module named 'matplotlib'
What explains this? What should I do to fix this? Why does the IPython shell have access to a package that Jupyter notebook doesn't have access to?
Solution
The problem seems to be that my version of jupyter notebook uses python 3 by default, whereas my version of the ipython shell uses python 2.
I followed these instructions to install a python 2 kernel for use in jupyter notebook.
Then I switched my notebook to use the python 2 kernel by selecting Kernel > Change kernel inside the notebook.
This allowed me to import all the packages I was able to import in the shell.
Answered By - dbliss
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.