Jupyter Notebook Anaconda cannot open because of syntax error with dateutil

Viewed 2489

I'm trying to open Jupyter Notebook with Anaconda navigator (on Mac OSX) and I cannot open it properly. I keep getting this message in my terminal.

File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/dateutil/parser.py", line 158
    l.append("%s=%s" % (attr, `value`))
                              ^
SyntaxError: invalid syntax
logout
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.

[Process completed]

I tried checking my default version of python and it says my default version is python 3.6. However when I got to pip and try to install dateutil it says

pip install python-dateutil
Requirement already satisfied: python-dateutil in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python

I am having trouble since I have multiple versions of python on my computer. What can I do?

2 Answers

I was having the same problem with anconda 4.5.1 python 3.6. Reinstalling the package solved the problem for me.

pip uninstall python-dateutil
pip install python-dateutil

I think you need to change the python version for Anaconda. Currently, your Anaconda looks into python 2.7 directory and I think you need to switch to python 3.6 version.

You can create environments for different versions of Python and installed packages by:

conda create -n py36 python=3.6 anaconda

py36 is the name of the python 3.6.0 environment.

Then you can activate an environment by

source activate py36 

Helpful links:

Using pip in an environment

Managing Python in Anaconda

Managing Environments

Hope this helps!

Related