使用PyCharm的Profiler时,“ImportError:无法导入名称cbook”

问题描述 投票:4回答:3

我试图运行PyCharm分析器,但我收到以下错误消息:

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

我正在使用我已在终端切换到的conda环境:

$ source activate <env>

然后更新了matplotlib

$pip install matplotlib --upgrade

和六个只是为了好的措施

$pip install six --upgrade

(请注意,我还从我的环境的site-directory手动删除了这些包,并重新安装,只是因为--upgrade没有表现)

我看了herehere,两种解决方案都没有解决我的问题。

我还改变了PyCharm Run配置,使用我的每个conda环境,所有这些都会产生相同的错误。

请注意,在我使用常规执行代码的方法之前,探查器在以前工作过,并且代码工作正常。有没有人知道发生了什么?

谢谢

python matplotlib pycharm
3个回答
14
投票

我今天遇到了同样的错误,虽然可能是出于不同的原因 - matplotlib和/或6的包似乎被打破了。

通过降级到以前的版本来解决它:

conda install six=1.10.0
conda install matplotlib=2.0.2

2
投票

我在jupyter中有这个错误但不是IPython。与$ conda install matplotlib=2.0.2固定如上,但六个没有降级。不要忘记(正如我所做的)重启内核。


0
投票

我遇到过同样的问题。降级到matplotlib 2.0.2似乎解决了这个问题。

pip uninstall matplotlib
pip install matplotlib==2.0.2
© www.soinside.com 2019 - 2024. All rights reserved.