Matplotlib:导入错误没有名为_path的模块

时间:2021-09-12 18:10:02

I've been struggling for hours on a problem that is making me insane. I installed Python 2.7 with Cygwin and added Scipy, Numpy, Matplotlib (1.4.3) and Ipython. When I decided to run ipython --pylab I get the following error:

我一直在努力解决一个让我疯狂的问题。我用Cygwin安装了Python 2.7并添加了Scipy,Numpy,Matplotlib(1.4.3)和Ipython。当我决定运行ipython --pylab时,我收到以下错误:

/usr/lib/python2.7/site-packages/matplotlib/transforms.py in <module>()
 37 import numpy as np
 38 from numpy import ma
 ----> 39 from matplotlib._path import (affine_transform, count_bboxes_overlapping_bbox,
 40     update_path_extents)
 41 from numpy.linalg import inv

 ImportError: No module named _path

I spent hours on the internet, looking for a solution but nothing worked. I did notice that I am missing _path.so files in the matplotlib directory that everybody seems to have. Instead, I have two files: path.py and path.pyc. But I installed matplotlib directly from the official website using pip install and reinstalling it didn't make any difference. Does anyone have a little clue on what is going wrong? I would be incredibly grateful !!!

我在互联网上花了几个小时,寻找解决方案但没有任何效果。我注意到我在matplotlib目录中缺少_path.so文件,似乎每个人都有。相反,我有两个文件:path.py和path.pyc。但是我使用pip install直接从官方网站安装matplotlib并重新安装它没有任何区别。有没有人对出了什么问题有一点线索?我会非常感激!!!

3 个解决方案

#1


For others having this problem, in my case, the solution was simple. The problem was caused by having the wrong matplot library installed on your computer; creating an error in finding the correct matplotlib path. In my case, I had installed matplotlib on a different version of python. Simply update matplotlib on your computer, so that it is compatible with your current version of python:

对于有这个问题的其他人来说,在我的情况下,解决方案很简单。问题是由于您的计算机上安装了错误的matplot库引起的;在找到正确的matplotlib路径时创建错误。在我的例子中,我在不同版本的python上安装了matplotlib。只需在您的计算机上更新matplotlib,以便它与您当前的python版本兼容:

pip install --upgrade matplotlib

As for the post, I am unsure of what caused these big issues. Hope my tip can help anyone else stumbling upon this issue!

至于帖子,我不确定是什么原因引起了这些大问题。希望我的小费可以帮助其他任何人绊倒这个问题!

#2


I doubt that most of you brought here by Google have the problem I had, but just in case:

我怀疑你带来的大多数人都有我遇到的问题,但以防万一:

I got the above "ImportError: No module named _path" (on Fedora 17) because I was trying to make use of matplotlib by just setting sys.path to point to where I had built the latest version (1.5.1 at the time). Don't do that.

我得到了上面的“ImportError:没有名为_path的模块”(在Fedora 17上),因为我试图通过设置sys.path指向我构建最新版本(当时为1.5.1)来使用matplotlib 。不要那样做。

Once I ran "python setup.py install" (as root) to do a proper install (and got rid of my sys.path hack), the error was fixed.

一旦我运行“python setup.py install”(以root身份)进行正确的安装(并摆脱了我的sys.path hack),错误就得到了解决。

#3


The package matplotlib requires multiple dependencies (see them here). For me, the missing dependencies included pyparsing and kiwisolver, but your results my vary. Before you do any of these other things (reinstalling python or the library, etc...), make sure you have installed (pip install ...) all the libs in this list (link).

包matplotlib需要多个依赖项(在此处查看)。对我来说,缺少的依赖包括pyparsing和kiwisolver,但你的结果我的变化。在你做其他任何事情之前(重新安装python或库等),确保你已经安装(pip install ...)这个列表中的所有库(链接)。

#1


For others having this problem, in my case, the solution was simple. The problem was caused by having the wrong matplot library installed on your computer; creating an error in finding the correct matplotlib path. In my case, I had installed matplotlib on a different version of python. Simply update matplotlib on your computer, so that it is compatible with your current version of python:

对于有这个问题的其他人来说,在我的情况下,解决方案很简单。问题是由于您的计算机上安装了错误的matplot库引起的;在找到正确的matplotlib路径时创建错误。在我的例子中,我在不同版本的python上安装了matplotlib。只需在您的计算机上更新matplotlib,以便它与您当前的python版本兼容:

pip install --upgrade matplotlib

As for the post, I am unsure of what caused these big issues. Hope my tip can help anyone else stumbling upon this issue!

至于帖子,我不确定是什么原因引起了这些大问题。希望我的小费可以帮助其他任何人绊倒这个问题!

#2


I doubt that most of you brought here by Google have the problem I had, but just in case:

我怀疑你带来的大多数人都有我遇到的问题,但以防万一:

I got the above "ImportError: No module named _path" (on Fedora 17) because I was trying to make use of matplotlib by just setting sys.path to point to where I had built the latest version (1.5.1 at the time). Don't do that.

我得到了上面的“ImportError:没有名为_path的模块”(在Fedora 17上),因为我试图通过设置sys.path指向我构建最新版本(当时为1.5.1)来使用matplotlib 。不要那样做。

Once I ran "python setup.py install" (as root) to do a proper install (and got rid of my sys.path hack), the error was fixed.

一旦我运行“python setup.py install”(以root身份)进行正确的安装(并摆脱了我的sys.path hack),错误就得到了解决。

#3


The package matplotlib requires multiple dependencies (see them here). For me, the missing dependencies included pyparsing and kiwisolver, but your results my vary. Before you do any of these other things (reinstalling python or the library, etc...), make sure you have installed (pip install ...) all the libs in this list (link).

包matplotlib需要多个依赖项(在此处查看)。对我来说,缺少的依赖包括pyparsing和kiwisolver,但你的结果我的变化。在你做其他任何事情之前(重新安装python或库等),确保你已经安装(pip install ...)这个列表中的所有库(链接)。