问题
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:
/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 !!!
回答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:
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.
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.
回答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).
来源:https://stackoverflow.com/questions/30196585/matplotlib-import-error-no-module-named-path