1

I'm trying to teach myself Python via a few resources. One of said resources is a book titled "Doing Math with Python: Use Programming to Explore Algebra, Statistics, Calculus, and More" as well as "Computational Physics." Chapter 2 of the former is all about graphing.

I (thought that I) installed matplotlib. My terminal continues to tell me that I have done so, however, when I type the following into IDLE, I am presented with the following error message:

from pylab import * Traceback (most recent call last): File "", line 1, in from pylab import * ModuleNotFoundError: No module named 'pylab'

I thought pylab was included with matplotlib. I feel like I've tried everything short of selling my soul. Some input would be greatly appreciated.

ndmeiri
  • 4,979
  • 12
  • 37
  • 45
PhilSark
  • 11
  • 2
  • 1
    Please make your question shorter, reduce it to your actual problem. And change the title so it actually describes what you want. Like this people are unlikely to answer your question. – Elmar Peise Aug 22 '17 at 21:33
  • Try `import matplotlib.pylab as pylab`? EDIT: [This](https://stackoverflow.com/questions/11469336/what-is-the-difference-between-pylab-and-pyplot) might be more relevant. I've never used pylab, but frequently do `import matplotlib.pyplot as plt`. I don't think you need pylab tbh anymore – roganjosh Aug 22 '17 at 21:34
  • 1
    1) Why do you even use IDLE if macOS is shipped with Python already? Just open up Terminal and type in `python`. 2) If you installed `matplotlib` via `pip` then it's probably installed for that 'built-in' Python, so try importing pylab from there. – ForceBru Aug 22 '17 at 21:39
  • `pylab` *is* included with `matplotlib`, look at how `pylab` is defined/imported in the source code: [matplotlib/lib/pylab.py](https://github.com/matplotlib/matplotlib/blob/38be7aeaaac3691560aeadafe46722dda427ef47/lib/pylab.py): `from matplotlib.pylab import *; import matplotlib.pylab` which you can reproduce using [the command roganjosh mentioned above](https://stackoverflow.com/questions/45827274/im-having-pylab-problems-om-mac-osx#comment78612742_45827274) – chickity china chinese chicken Aug 22 '17 at 21:44
  • @downshift since the answer I linked to was edited by one of the core developers of matplotlib, I'm guessing that pylab will die a death soon. Similar to the discussions about `matrix` in numpy. I guess now that python scientifc stack is established, there's no need to try retain the fluffier aspects that make transition over from MatLab easier. – roganjosh Aug 22 '17 at 21:49
  • Ok. I tried your suggestions. This is the resulting error message: – PhilSark Aug 22 '17 at 21:50
  • Traceback (most recent call last): File "", line 1, in File "/Users/philipsarkisian/miniconda3/lib/python3.6/site-packages/matplotlib/pylab.py", line 257, in from matplotlib import cbook, mlab, pyplot as plt File "/Users/philipsarkisian/miniconda3/lib/python3.6/site-packages/matplotlib/pyplot.py", line 115, in _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup() – PhilSark Aug 22 '17 at 21:52
  • globals(),locals(),[backend_name],0) File "/Users/philipsarkisian/miniconda3/lib/python3.6/site-packages/matplotlib/backends/backend_macosx.py", line 19, in from matplotlib.backends import _macosx – PhilSark Aug 22 '17 at 21:52
  • RuntimeError: Python is not installed as a framework. The Mac OS X backend will not be able to function correctly if Python is not installed as a framework. See the Python documentation for more information on installing Python as a framework on Mac OS X. Please either reinstall Python as a framework, or try one of the other backends. If you are using (Ana)Conda please install python.app and replace the use of 'python' with 'pythonw'. See 'Working with Matplotlib on OSX' in the Matplotlib FAQ for more information. – PhilSark Aug 22 '17 at 21:52
  • I've also gotten the error message saying that matplotlib module has not been found, even though I've installed it a million different ways. – PhilSark Aug 22 '17 at 21:57
  • 1
    oh you're using `python3.6` in`miniconda3`. I've no idea about this `miniconda3`, but this blog [python 3 support in anaconda](https://www.continuum.io/blog/developer-blog/python-3-support-anaconda) suggests `conda install matplotlib` should install `matplotlib` (and states *"the matplotlib module isn't installed by default."* https://www.continuum.io/blog/developer-blog/python-3-support-anaconda#comment-1277269941 – chickity china chinese chicken Aug 22 '17 at 22:01
  • I figured out what was wrong. I didn't have the most recent editions of, both, python and matplotlib installed on my computer. Thanks for your suggestions, y'all. – PhilSark Aug 23 '17 at 21:36

0 Answers0