For the depiction in pylab, when I run it as follows, the module comes out that figure cannot be used.
pylab uses the latest version with
$pip install --upgrade pylab .
pylab.figure() , but also
pylab.show() , etc. will throw similar errors. I would appreciate it if you could tell me the solution.
Python 2.7.10 (v2.7.10:15c95b7d81dc, May 23 2015, 09:33:12) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import pylab as pl >>> pl.figure() Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'module' object has no attribute 'figure'
pylab is stored in the following.
The pylab used is as follows.
>>> import pylab >>> print(pylab.__file__) /usr/local/lib/python2.7/site-packages/pylab/__init__.pyc
Also, python uses the one installed by brew.
$ which python /usr/local/bin/python
The "pylab module" provided by the package "pylab" was different from the "pylab module" in matplotlib.
The package "pylab" seems to be an empty package for installing various packages .
Like the question, installing with it can be confusing.
The module name
pylab will be taken by this empty module.
This should be removed as
sudo pip2 uninstall pylab etc.
(What is it? I think it's just a trap )
You can install matplotlib with
sudo pip2 install matplotlib , and now you can use pylab provided by matplotlib.
The matplotlib documentation says that pylab is deprecated, so use matplotlib.pyplot, but this wasn't related to this issue.
many examples use pylab, it is no longer recommended.
How to check where the imported pylab is
import pylab print(pylab.__file__)
In some cases, you have inadvertently created a file called pylab.py in your working directory.