Issue
I am having an issue trying to import pandas on my Jupyter notebook using Python 3.10. I am using a MacOS computer with VSCode as my IDE.
I have installed pandas on my machine using Homebrew brew install pandas
and it works just fine when I use import pandas
in my IDE. However, it fails in Jupyter.
I open jupyter as normal with jupyter notebook
. I then attempt the simple command import pandas
I get an error message that says:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
Input In [1], in <cell line: 1>()
----> 1 import pandas
ModuleNotFoundError: No module named 'pandas'
I did a quick search on Stack and across Google and everybody tells me to run !pip install pandas
in the Jupyter notebook but since I am using PHP3.10, I have opted for !pip3 install pandas
. When I do this, Jupyter tells me:
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: pandas in /Users/daveshields/Library/Python/3.10/lib/python/site-packages (1.4.2)
Requirement already satisfied: python-dateutil>=2.8.1 in /Users/daveshields/Library/Python/3.10/lib/python/site-packages (from pandas) (2.8.2)
Requirement already satisfied: numpy>=1.21.0 in /Users/daveshields/Library/Python/3.10/lib/python/site-packages (from pandas) (1.22.4)
Requirement already satisfied: pytz>=2020.1 in /Users/daveshields/Library/Python/3.10/lib/python/site-packages (from pandas) (2022.1)
Requirement already satisfied: six>=1.5 in /Users/daveshields/Library/Python/3.10/lib/python/site-packages (from python-dateutil>=2.8.1->pandas) (1.16.0)
I close Jupyter and then open it again and attempt import pandas
and I get the exact same message. Can anyone help me figure out why this is happening? I am doing the Python Master Course by Ardit Sulce on Udemy but I can't progress any further in the course until I can figure this out. TYIA.
Dave Shields
Solution
Thank you so much to Wayne!
Amazingly the %pip install pandas
worked! I did that and it installed pandas and numpy.
I ran import pandas
and then df1 = pandas.DataFrame([[2,4,6],[10,30,30]])
.
After that I was able to successfully use print(df1)
and it worked!
Answered By - Dave Shields
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.