Saber Alex
Saber Alex

Reputation: 1723

Unable to import pandas on Jupyter Notebook

I've installed both pandas and jupyter notebook on my virtualenvs(python3). When I check which jupyter, it's correctly refer to my envs. However, I can't import pandas when I run it in the browser. When I run the ipython, I can import the pandas module though...

ImportError: No module named 'pandas'

Any help?

Upvotes: 1

Views: 9455

Answers (2)

Félix Fu
Félix Fu

Reputation: 457

If you land here looking for the answer, this is it (taken from the question @Aleksey Bilogur refers):

source activate ENVNAME
pip install ipykernel
python -m ipykernel install --user --name ENVNAME --display-name "Python (whatever you want to call it)"

It is really important that you install ipykernel in your virtualenv and that you launch jupyter notebook also from you ENVNAME.

Once you've done that, check if the path to your ENVNAME appears when executing from your notebook:

import sys
sys.path

If it does not, something went wrong and it won't work.

Upvotes: 3

Aleksey Bilogur
Aleksey Bilogur

Reputation: 3846

Jupyter is built with the Anaconda Python distribution (and the conda environment manager) in mind. Although some work has been done to remediate this issue, using jupyter with virtualenv is discouraged.

In this case it sounds like jupyter is using your default (root) Python environment, because it's not aware of your virtualenv one. See here for details on how to fix that.

Upvotes: 4

Related Questions