简体   繁体   中英

from pylab import plot

I have installed python 3.5 on a computer running Scientific Linux 6.5. I have set up a virtual environment, and I have installed numpy and pylab using pip version 8.1.2.

My problem is this, when I try to do the simplest of tasks, ie import plot from pylab, I get this:

$ python
Python 3.5.1 (default, May 10 2016, 12:41:42) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-16)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from pylab import plot
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name 'plot'
>>> 

Here is some other information:

>>> pylab.__version__
'0.1.0'
>>> matplotlib.__version__
'1.5.1'
>>> 

I don't find any help through Google, and the only question similar to this doesn't seem relevant to me. What is going on?

After coming back over a weekend break and trying again with iPython, I got a different error message, which led to another Google search...

I found the answer here: Pylab - 'module' object has no attribute 'Figure'

My mistake was to think that pip install pylab would work as expected!

Installing pylab installs matplotlib , which apparently also installs pylab . This recursion causes the error. For me, uninstalling pylab and matplotlib and re-installing matplotlib alone fixed the error. I hope this helps!

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