7

I'm running the jupyter notebook (Enthought Canopy python distribution 2.7) on Mac OSX (v 10.13.6). When I try to import pandas (import pandas as pd), I am getting the complaint: ImportError: dateutil 2.5.0 is the minimum required version. I have these package versions:

  • Canopy version 2.1.3.3542 (64 bit)
  • jupyter version 1.0.0-25
  • pandas version 0.23.1-1
  • python_dateutil version 2.6.0-1

I'm not getting this complaint when I run with the Canopy Editor so it must be some jupyter compatibility problem. Does anyone have a solution on how to fix this? All was well a few months ago until I recently (and mindlessly) allowed an update of my packages.

user1745564
  • 159
  • 1
  • 2
  • 8
  • The dependencies for a package (such as pandas) must be installed *before* the package is installed. If you suspect the order of installation might be the problem, try uninstalling pandas then reinstalling it (now that dateutil is already installed). – unutbu Jul 23 '18 at 00:48
  • I had reinstalled jupyter but am still getting the problem. The fact that I can import pandas in the editor and use it successfully makes me think that pandas isn't the issue. – user1745564 Jul 23 '18 at 00:54
  • Do you have more than one version of python installed? (Installed packages are installed only for one python installation. So not only must dateutil be installed, but it must be installed for the same python that jupyter is running.) – unutbu Jul 23 '18 at 00:55
  • There is a Mac python version installed; however, I am invoking the Canopy version of python by starting Canopy, going to the Canopy menu item of Tools > Canopy Terminal. The upgrade of the python packages were performed using the Canopy Package Manager. When I type "which jupyter" in the Canopy terminal, I see that I am using the Canopy Enthought jupyter package, /Library/Frameworks/EPD64.framework/Versions/Current/bin/jupyter. Again, I haven't had this problem until now, so I feel confident that the Mac distribution of python isn't the problem and that I'm using the Enthought distribution – user1745564 Jul 23 '18 at 01:06
  • Looks like my Canopy version is old. There is a 2.1.9 version out there. Maybe I should upgrade. Crossing my fingers. – user1745564 Jul 23 '18 at 01:11
  • 1
    I upgraded to Canopy 2.1.9. No problems with importing pandas without applying the numerous updates. Problems come back when I upgrade all the packages, so there is some incompatibility with one or more package upgrades. I guess I'll try to avoid any upgrades for now. – user1745564 Jul 23 '18 at 01:45
  • Are you absolutely sure you're running this code in the Canopy Python, not the pre-installed Apple Python? When you start up the notebook, it should show you a banner that includes the version number; Apple's Python is 2.7.10 but a new Canopy install is presumably newer. Or, just `import sys; print sys.executable`. If it's `/usr/bin/python` or a path starting with `/System`, it's Apple's. – abarnert Jul 23 '18 at 01:50
  • The reason I ask is that Apple pre-installs an old version of `dateutil` as part of their Extras, which are a huge pain to override with upgrades (because Apple designed their setup in the pre-`pip` era and hasn't bothered to update the way things work since), and people trying to `pip install pandas` into it often get problems exactly like this. Sometimes the `pip` fails because it tries and fails to update `dateutil`, sometimes it thinks it worked but then `import pandas` complains about a too-old `dateutil`, … – abarnert Jul 23 '18 at 01:52
  • I did the import sys and print sys.executable. I got /Users/babsii/Library/Enthought/Canopy/edm/envs/User/Resources/Python.app/Contents/MacOS/Python. When I do all the 42 upgrades, quit and restart Canopy and the jupyter notebook, I get the same result for the sys.executable. One of the package upgrades is pip, however, when I do in the Canopy Terminal shell a "which pip", I get /Users/babsii/Library/Enthought/Canopy/edm/envs/User/bin/pip, not the Apple version. I'm not sure why I would only get the problem when I use the jupyter notebook and not in both the Canopy editor and the notebook. – user1745564 Jul 23 '18 at 02:50
  • When this happened to me, the reason was that I just happened to be in a directory which had a conflicting dateutil package in it and got imported first instead of the pip3 installed one. – Bemmu May 25 '19 at 15:53

5 Answers5

16

For me to solve this issue I had to install python-dateutil library.

pip install python-dateutil==2.5.0

This was resolved the issue.

GPrathap
  • 7,336
  • 7
  • 65
  • 83
3

I had this same issue using the newest pandas version - downgrading to pandas 0.22.0 fixes the problem.

pip install pandas==0.22.0

0

Installed Canopy version 2.1.9. The downloaded version worked without updating any of the packages called out by the Canopy Package Manager. Updated all the packages, but then the "import pandas as pd" failed when using the jupyter notebook. Downgraded the notebook package from 4.4.1-5 to 4.4.1-4 which cascaded to 35 additional package downgrades. Retested the import of pandas and the issue seems to have disappeared.

user1745564
  • 159
  • 1
  • 2
  • 8
  • This might be a build error. Could you file a report from the Canopy Help menu's Report Feedback/Bug item? Please include a link to this SO question. Thanks. – Jonathan March Jul 23 '18 at 17:19
0

Following command worked for me

sudo -H pip install --ignore-installed -U ipython

sudo -H pip install --ignore-installed -U pyzmq
0

The issue is with the pandas lib

downgrade using the command below

pip install pandas==0.22.0