简体   繁体   中英

Pandas import error: missing “pytz”. But works fine in console

I'm using PyCharm and running a script by clicking the "Run" button, which executes the script in the "Run" environment. Interpreter is Anaconda 3.5. The script begins with import pandas as pd . It's been always working perfectly until just now when I clicked 'Run' I got an unexpected error raised:

D:\Anaconda3\python.exe MY_PATH
Traceback (most recent call last):
  File MY_PATH, line 2, in <module>
    import pandas as pd
  File "D:\Anaconda3\lib\site-packages\pandas\__init__.py", line 19, in <module>
    "Missing required dependencies {0}".format(missing_dependencies))
ImportError: Missing required dependencies ['pytz']

This error persists even after I uninstalled and reinstalled both pytz and pandas .

On the other hand, pandas has been always working properly in the IPython console environment (with the same interpreter as the "Run" environment). Such an error never occurs in the console.

What could be wrong? Please help me. Thanks!


As Julian noted, the problem is most likely due to pytz being absent from the "Run" environment, although it's present in the IPython console environment. So how can I restore pytz in the "Run" environment in PyCharm ?

您可以尝试一次并检查错误是否仍然存在,

pip install python-dateutil pytz --force-reinstall --upgrade

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM