NameError

Michael Torrie torriem at gmail.com
Thu Nov 24 12:45:40 EST 2016


As alister said, please do not just hit reply and type your message at
the top.  Instead, place your reply below the quoted text you are
replying too.  This is not hard.  I realize there's a language barrier,
but please patiently read what alister said and understand what he's
saying. I know you're impatient to get Python working, but take a few
minutes to understand what we're saying.  See below for my reply to your
message (and an example of posting below quoted text).

On 11/24/2016 08:05 AM, Cai Gengyang wrote:
> CaiGengYangs-MacBook-Pro:~ CaiGengYang$ python
> 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 pygame
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> ImportError: No module named pygame
>>>> "import pygame"
> 'import pygame'
>>>>

Quite likely you are not running the version of Python that was
installed with brew.  Instead you are running the system version of
python that came with OS X, which is likely at /usr/bin/python.  The
Brew-installed python is, if I recall correctly, installed to
/usr/local/bin, and is Python 3.  So the correct command-line input
would be:

/usr/local/bin/python3

That should bring up the python prompt and if you were successful with
brew installing pygame, you should be able to import pygame and not get
an ImportError.




More information about the Python-list mailing list