I am using the Jupyter notebook with Python 3 selected. On the first line of a cell I am entering:
import pandas as pd
The error I get from the notebook is, ImportError: No module named 'pandas'. How can I install pandas to the jupyter notebook? The computer I launched the Jupyter notebook from definitely has pandas.
I tried doing:
!pip install pandas
And it says it is already installed but for Python 2.7 at the bottom. My script shows it is a Python 3 script at the top though.
When I do echo $PATH in Ubuntu is shows that '/home/user/anaconda2/bin' is on the first entry. I think I may need to change this to be anaconda3?
UPDATE: When I try and launch a Python3 script through jupyter the command line which launched Jupyter gives me the error "ImportError: No module named 'IPython.paths'. Then there is a timeout waiting for 'kernel_info' reply. Additionally, I tried removing anaconda but still experience the same error. I have tried to make so many quick fixes now, that I am not sure what the next step is to get this working.
In most cases this error in Python generally raised: You haven't installed Pandas explicitly with pip install pandas. You may have different Python versions on your computer and Pandas is not installed for the particular version you're using.
In JupyterLab, create a new (Python 3) notebook: In the first cell of the notebook, you can import pandas and check the version with: Now you are ready to use pandas, and you can write your code in the next cells.
As your default python version is 2.x , if you don't have any emphasis on the python 3.x you can try from the first by the below scripts.
pip install --upgrade pip pip install jupyter
then in jupyter notebook:
!pip install pandas
The version of notebook will be 2.x. Otherwise install pip3 by the below Linux commands.
sudo apt-get install python3-setuptools sudo easy_install3 pip
now you can add pandas to the notebook by !pip3 install pandas
.
This worked for me
in Jupiter notebook
import sys print(sys.executable)
copy path eg:
/Library/Frameworks/Python.framework/Versions/3.7/bin/python3
install the module on the terminal like this.
/Library/Frameworks/Python.framework/Versions/3.7/bin/python3 -m pip install pandas
Or it can be installed directly from Jupyter Cell as follows
! /Library/Frameworks/Python.framework/Versions/3.7/bin/python3 -m pip install pandas
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With