Research
-
[X] I have searched the [pandas] tag on StackOverflow for similar questions.
-
[X] I have asked my usage related question on StackOverflow.
Link to question on StackOverflow
https://stackoverflow.com/questions/74434416/i-cannot-import-pandas-into-jupyter-lab-attributeerror-module-numpy-has-n
Question about pandas
I did brew upgrade today. In jupyter lab as normal, import Pandas as pd I
results in the following error
AttributeError Traceback (most recent call last)
/var/folders/3t/m3cn50hx38l29x6_mv9t0sdw0000gn/T/ipykernel_5766/2035458946.py in <module>
----> 1 import pandas as pd
/opt/homebrew/lib/python3.9/site-packages/pandas/__init__.py in <module>
20
21 # numpy compat
---> 22 from pandas.compat.numpy import (
23 np_version_under1p17 as _np_version_under1p17,
24 np_version_under1p18 as _np_version_under1p18,
/opt/homebrew/lib/python3.9/site-packages/pandas/compat/__init__.py in <module>
12 import warnings
13
---> 14 from pandas._typing import F
15
16 PY38 = sys.version_info >= (3, 8)
/opt/homebrew/lib/python3.9/site-packages/pandas/_typing.py in <module>
52 # array-like
53
---> 54 AnyArrayLike = TypeVar("AnyArrayLike", "ExtensionArray", "Index", "Series", np.ndarray)
55 ArrayLike = TypeVar("ArrayLike", "ExtensionArray", np.ndarray)
56
AttributeError: module 'numpy' has no attribute 'ndarray'
No problem importing numpy
My problem is that I am inexperienced in debugging.
I have found many reports on Stackoverflow regarding numpy attribute errors, the two that relate to ndarray suggest uninstalling numpy and reinstalling it. I have done this for both numpy and pandas and neither has helped.
This report suggest checking the location of the numpy package. Mine is in the correct brew location /opt/homebrew/opt/numpy
.
I have also tried uninstalling and reinstalling jupyter lab.
Any help on how to solve this problem would be great.
Comment From: MarcoGorelli
Hi @capnahab
Thanks for your report - I suggest you create a new virtual environment and start over, looks like something's gone wrong with installation, doesn't look like an issue in pandas itself
https://realpython.com/python-virtual-environments-a-primer/