简体   繁体   中英

Matplotlib + Pylab import error

Been struggling to resolve this for most of the day, hoping someone can assist...

I'm running python 2.7, have installed matplotlib but when attempting to get started and import pylab I receive errors saying that no module is found, even when there is clearly a pylab module in the matplotlib directory and we're using:

from matplotlib.pylab import *

Any ideas?

Solved!

I had the script I was testing with in the same directory as the original 'matplotlib' directory from install. Using print sys.path I saw this was where the script was looking for the pylab files rather than the matplotlib directory in site-packages.

Thanks.

An easy mistake could be to name the file the same way as the module. I already made the mistake for example, when trying curses, and naming the file curses.py. I had to remove the .py and .pyc files to make it works.

尝试像这样导入:

from pylab import *

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM