Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'ImportError: cannot import name cbook' when using PyCharm's Profiler

I am trying to run the PyCharm profiler but I get the following error message:

Traceback (most recent call last):
  File "/home/b3053674/ProgramFiles/pycharm-2017.1.4/helpers/profiler/run_profiler.py", line 164, in <module>
    profiler.run(file)
  File "/home/b3053674/ProgramFiles/pycharm-2017.1.4/helpers/profiler/run_profiler.py", line 89, in run
    execfile(file, globals, globals)  # execute the script
  File "/home/b3053674/Documents/pycotools/pycotools/tasks.py", line 38, in <module>
    import viz,errors, misc, _base, model
  File "/home/b3053674/Documents/pycotools/pycotools/viz.py", line 53, in <module>
    import matplotlib.pyplot as plt
  File "/home/b3053674/anaconda2/envs/pycotools/lib/python2.7/site-packages/matplotlib/__init__.py", line 124, in <module>
    from . import cbook
ImportError: cannot import name cbook
Snapshot saved to /home/b3053674/.PyCharm2017.1/system/snapshots/pycotools30.pstat

Process finished with exit code 1

I am using a conda environment which I have switched to in the terminal:

$ source activate <env>

then updated matplotlib

$pip install matplotlib --upgrade

and six just for good measure

$pip install six --upgrade

(note that I've also manually deleted these packages from site-directory of my environment and reinstalled just incase --upgrade wasn't behaving)

I've looked here and here and neither solutions solved my problem.

I've also switched the PyCharm Run configurations to use each of my conda environments in turn all of which produce the same error.

Note that the profiler has worked before in the past and the code works fine when I use the normal way of executing the code. Does anybody have any idea of what is going on?

Thanks

like image 942
CiaranWelsh Avatar asked Oct 09 '17 17:10

CiaranWelsh


1 Answers

I encountered the same error today, although probably for a different reason - the packages for matplotlib and/or six appear to be broken.

Resolved it by downgrading to the previous versions:

conda install six=1.10.0
conda install matplotlib=2.0.2
like image 104
janhefti Avatar answered Oct 13 '22 08:10

janhefti