Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dateutil & Pytz missing dependencies - Python

Im trying to run a code for portfolio optimization and i get the following error right on import of pandas.

Traceback (most recent call last):
  File "/Users/***/Desktop/Markowitz-master/MarkowitzOpt.py", line 2, in <module>
    from pandas import Series, DataFrame
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas/__init__.py", line 18, in <module>
    raise ImportError("Missing required dependencies {0}".format(missing_dependencies))
ImportError: Missing required dependencies ['pytz', 'dateutil']

I used pip freeze to check all installed packages, and both puts and dateutil are installed.

Any insights would be appreciated!!!

like image 569
Eliot T. Bounader Avatar asked Feb 05 '23 02:02

Eliot T. Bounader


2 Answers

dateutil can get confused with python-dateutil, try the following:

pip install python-dateutil pytz --force-reinstall --upgrade
like image 106
Benjamin Rowell Avatar answered Feb 07 '23 16:02

Benjamin Rowell


If you are also using conda you may have to also update the packages in conda.

conda update python-dateutil pytz

This worked for me.

Note: I was getting the error when I attempted to load pandas in IPython for Python 2.7.15. I was not in a conda virtual env but the ipython install that was being loaded came from conda. Updating the packages in conda solved the issue.

like image 20
gavinest Avatar answered Feb 07 '23 17:02

gavinest