3

I am working with PyBrain and in the documentation it uses PyLab... I try importing PyLab and that works, however when I try using any of the modules in it python returns an error.

    >>> import pylab
    >>> dir(pylab)
    ['__author__', '__builtins__', '__doc__', '__email__', '__file__',   '__name__', '__package__', '__path__', '__version__']
    >>> 

PyLab appears to be installed correctly but it doesn't have any contents.

mcchucklezz
  • 376
  • 1
  • 16
  • Try print(pylab.__file__) and see it is pointing to correct installation on your hard disk. Another potential cause is circular swallowed import error caused by bad coding practices. – Mikko Ohtamaa Jun 17 '15 at 00:39

1 Answers1

2

There are many reasons why that happen… So let's find out what's happening.

The PyLab you've installed is very likely the one from pypi:

which is actually the one here:

and when you look at the files, it's matching what you're saying:

it's quite empty ☺

Though, if you install it, it's gonna install you a lot of dependencies for scientific development:

Though, since you've installed the pylab package, you've got matplotlib installed, and thus you can use the pylab which is actually part of matplotlib:

So if you do from matplotlib.pylab import * you should get started!

HTH

Community
  • 1
  • 1
zmo
  • 24,463
  • 4
  • 54
  • 90
  • I strongly discourage doing `from matplotlib.pylab import *` specifically and the use of the `pylab` name space in general. Explicitly use `import numpy as np` and `import matplotlib.pyplot as plt`. It helps to keep things organized and prevents issues like this http://stackoverflow.com/questions/18774388/re-import-aliased-shadowed-python-built-in-methods – tacaswell Jun 17 '15 at 01:58