Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Matplotlib Doesn't Work
#1
Hi everyone!

I successfully downloaded both Pygame and Matplotlib on my Mac (OSX), but neither seem to work when I import them.

Matplotlib was successfully installed using Pip3, but I get this message when trying to use it: 
Error:
Traceback (most recent call last):   File "/Users/ianscalzo/Desktop/python_work/matplotlib.py", line 1, in <module>     import matplotlib.pyplot as plt   File "/Users/ianscalzo/Desktop/python_work/matplotlib.py", line 1, in <module>     import matplotlib.pyplot as plt ImportError: No module named 'matplotlib.pyplot'; 'matplotlib' is not a package
I also successfully installed Pygame using Homebrew, but that doesn't work either. I get this message while trying to run it:
Error:
Traceback (most recent call last):   File "/Users/ianscalzo/Desktop/alien_invsion/game_test.py", line 3, in <module>     import pygame ImportError: No module named 'pygame'
Please help me out!
Quote
#2
Add path to the modules in PYTHONPATH environment

If they are installed with pip, this can help you to see where they are located:

pip show pygame
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Quote
#3
This is what I got for Pyame:

Name: pygame
Version: 1.9.4.dev0
Summary: Python Game Development
Home-page: http://www.pygame.org
Author: Pete Shinners, Rene Dudfield, Marcus von Appen, Bob Pendleton, others...
Author-email: pygame@seul.org
License: LGPL
Location: /usr/local/lib/python3.6/site-packages
Requires: 

And this is what I got for MatPlotLib:

Name: matplotlib
Version: 2.0.0
Summary: Python plotting package
Home-page: http://matplotlib.org
Author: John D. Hunter, Michael Droettboom
Author-email: matplotlib-users@python.org
License: BSD
Location: /Users/ianscalzo/Library/Python/3.6/lib/python/site-packages
Requires: python-dateutil, pyparsing, cycler, six, numpy, pytz
Quote
#4
I'm almost certain that the problem with the matplotlib is because your file is also named matplotlib. Select different name for your file.
wavic and snippsat like this post
Quote
#5
(Feb-27-2017, 07:15 PM)buran Wrote: I'm almost certain that the problem with the matplotlib is because your file is also named matplotlib. Select different name for your file.

Wow, I always forgot for this "option". It is named that way. As I see it in the error mesage.
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Quote
#6
I renamed the file, but still get the same error message:

Traceback (most recent call last):
  File "/Users/ianscalzo/Desktop/python_work/plotting_test.py", line 1, in <module>
    import matplotlib as plt
  File "/Users/ianscalzo/Desktop/python_work/matplotlib.py", line 4, in <module>
    plt.plot(squares)
AttributeError: module 'matplotlib' has no attribute 'plot

Also, the filename issue couldn't be the reason I'm getting the error in Pygame as well. Could the Pygame error be due to the fact that it's a 32-Bit Pygame and not 64-Bit?
Quote
#7
Well, according to your traceback you have another matplotlib.py in your python-work folder and it imports that file. Note that it's different error this time...
For more info check the docs for The Module Search Path
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  cx_Freeze doesn't seem to work owenwalker65 7 9,385 Dec-07-2017, 02:23 AM
Last Post: issac_n

Forum Jump:


Users browsing this thread: 1 Guest(s)