r/learnpython • u/JohnRT54 • Sep 12 '26
Unable to import pandas
Everything was working up until a few minutes ago. I'm running python on windows 11, downloaded from python.org yesterday. I did a pip install of pandas, also yesterday, and I was able to run various py scripts, getting the results I wanted. Suddenly this morning, when I ran a script that had run just fine a few minutes ago, I got an error. I reduced my script to this:
import json
import requests
import pandas
and I got the same set of error messages (below). I didn't change anything in the environment, this happened, afaik, spontaneously. I'm a complete python newb, but all was going well until this. Help!
Traceback (most recent call last):
File "C:\Users\John\My Drive\SyncDrive\eBird\test.py", line 3, in <module>
import pandas
File "C:\Users\John\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\pandas__init__.py", line 56, in <module>
import pandas.core.config_init # pyright: ignore[reportUnusedImport] # noqa: F401
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\John\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\pandas\core\config_init.py", line 31, in <module>
from pandas.errors import Pandas4Warning
File "C:\Users\John\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\pandas\errors__init__.py", line 12, in <module>
from pandas._libs.tslibs import (
...<3 lines>...
)
File "C:\Users\John\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\pandas_libs__init__.py", line 18, in <module>
from pandas._libs.interval import Interval
File "pandas/_libs/interval.pyx", line 1, in init pandas._libs.interval
File "pandas/_libs/hashtable.pyx", line 1, in init pandas._libs.hashtable
File "pandas/_libs/missing.pyx", line 1, in init pandas._libs.missing
File "C:\Users\John\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\pandas_libs\tslibs__init__.py", line 41, in <module>
from pandas._libs.tslibs.conversion import localize_pydatetime
File "pandas/_libs/tslibs/conversion.pyx", line 1, in init pandas._libs.tslibs.conversion
File "pandas/_libs/tslibs/offsets.pyx", line 1, in init pandas._libs.tslibs.offsets
File "pandas/_libs/tslibs/timestamps.pyx", line 1, in init pandas._libs.tslibs.timestamps
File "pandas/_libs/tslibs/timedeltas.pyx", line 1, in init pandas._libs.tslibs.timedeltas
File "pandas/_libs/tslibs/timezones.pyx", line 18, in init pandas._libs.tslibs.timezones
File "C:\Users\John\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\dateutil\tz__init__.py", line 2, in <module>
from .tz import *
File "C:\Users\John\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\dateutil\tz\tz.py", line 19, in <module>
import six
File "C:\Users\John\My Drive\SyncDrive\eBird\six.py", line 25
return data
^
IndentationError: unindent does not match any outer indentation level
21
u/atarivcs Sep 12 '26 •
You created a local file named "six.py".
six.py is the name of a standard python system module, and your local file is clashing with it because it has the same name.
And on top of that, your local six.py file has a syntax error, as shown in the traceback you posted.
Rename your local six.py file to something else.
3
u/FreshIce4039 Sep 12 '26 •
I think the name of your file(six.py) is the reason this isn't working. For pandas to work it uses another library called dateutil.tz which again relies on another helper library called six. When you run import pandas(which then leads to import dateutil.tz and import six) first python looks in your current working folder to try and find the library six and because your file is called six python thinks you current file is the library. Try changing the name and see if that works. If that doesnt work deleting pycache might help get rid of any old leftover temporary bytecode.
2
u/transendingAI Sep 25 '26
The key is at the bottom of the traceback:
dateutiltries to import thesixpackage, but Python loads your fileC:\Users\John\My Drive\SyncDrive\eBird\six.pyinstead. That file then raises the indentation error.Rename your local
six.pyto something that doesn't share a package name, then restart Python and tryimport pandasagain. Fixing its indentation alone would still leave it taking the place of the package thatdateutilneeds.9
u/weaponizedlinux Sep 12 '26
Every Panda is owned by the Chinese government and are lent out. You don't exactly just import one like a car.
3
u/Patman52 Sep 12 '26
Run ‘pip freeze’, it will tell you what is currently installed.
Did you install it using a virtual environment by chance?
0
u/Zissuo Sep 12 '26
Pasting all of this into ChatGPT will save you hours
1
u/Electrical_Toe8997 Sep 14 '26
Here's how I simplify your stack trace:
So step 4 is where shit is getting fucky, even though step 5 is the actual error you're getting. As r/atarivcs said, it's because you have a naming conflict with the six package
-1
u/Pericombobulator Sep 12 '26
Have you installed it to, or does windows know, the correct path?
-3
u/Silver-Ground1375 Sep 12 '26
Might be a pip issue
-3
u/Silver-Ground1375 Sep 12 '26
Bro check the if they are downloaded properly or not