使用PyCharm的Profiler时出现

使用PyCharm的Profiler时出现

本文介绍了使用PyCharm的Profiler时出现"ImportError:无法导入名称cbook"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试运行PyCharm探查器,但收到以下错误消息:

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

我使用的是在终端中切换到的 conda 环境:

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

$ source activate <env>

然后更新了matplotlib

then updated matplotlib

$pip install matplotlib --upgrade

还有六个只是很好的测量

and six just for good measure

$pip install six --upgrade

(请注意,我还从环境的站点目录中手动删除了这些软件包,并重新安装了以防 --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.

我还切换了PyCharm Run 配置,依次使用我的每个conda环境,所有这些环境都会产生相同的错误.

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?

谢谢

推荐答案

我今天遇到了同样的错误,但可能是出于不同的原因 - matplotlib 和/或 6 的包似乎已损坏.

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

这篇关于使用PyCharm的Profiler时出现"ImportError:无法导入名称cbook"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 10:15