#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Location
    Essex, England
    Posts
    4
    Rep Power
    0

    Incredibly entry level question


    Hello,

    I have started looking into pygame and python recently and really think I would like to give it a go, but am falling at the very first hurdle.

    I have installed both python and pygame but when I type
    "import pygame, sys" as instructed by a tutorial I am following I get a message telling me there is no such module.

    The various versions and compatibility issues are ridiculously confusing for me (I know that doesn't bode well). I have tried installing an earlier python (2.7) but the error message in red still happens, although its much longer now.

    Could it be something to do with my computer not looking in the right place for pygame?

    I have noticed that upon installation a folder has been created called "developer" and pygame resides inside there, as opposed to the Python 2.7 folder.

    I am on OSX 10.6.8

    Thanks.
  2. #2
  3. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,856
    Rep Power
    481
    You're trying to use a package that doesn't come with the standard python distribution. I don't consider that an "entry level" problem. OSX is Apple's unix?

    Moving your pygame directory into the python library site packages directory might work. Hmm, I don't have a site packages directory. Never mind that.

    You could modify your python path environment variable and start python something like this:

    Code:
    $ PYTHONPATH=/usr/xxx/yyyy/developer:$PYTHONPATH python
    You could change your ~/.bashrc file (or whatever you use for a shell)
    You could make an alias
    Code:
    $ alias PYTHON="PYTHONPATH=/usr/xxx/yyyy/developer:$PYTHONPATH python"
    [code]Code tags[/code] are essential for python code and Makefiles!
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Location
    Essex, England
    Posts
    4
    Rep Power
    0
    Thats really weird then, because all the tutorials etc I have been looking at just start talking about using pygame/python like its no big deal at all. Not even mentioning that it's a pain in the *** to actually get to work.

    I will give your method a go in a sec and see how I get on, thanks for the help.

    Comments on this post

    • b49P23TIvg agrees : I could be a freak!
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Location
    Essex, England
    Posts
    4
    Rep Power
    0
    Bah, I am finding it hard to believe that they made the software this difficult to install. Are you sure theres no easy way to get python and pygame working together?
  8. #5
  9. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,856
    Rep Power
    481
    on my system pygame is installed in
    Code:
    $ locate pygame
    /usr/include/python2.7/pygame
    /usr/include/python2.7/pygame/bitmask.h
    ...
    /usr/lib/pyshared/python2.7/pygame
    /usr/lib/pyshared/python2.7/pygame/_arraysurfarray.so
    ...
    /usr/lib/python2.7/dist-packages/pygame
    /usr/lib/python2.7/dist-packages/pygame-1.9.1release.egg-info
    /usr/lib/python2.7/dist-packages/pygame/LGPL
    /usr/lib/python2.7/dist-packages/pygame/__init__.py
    ...
    /usr/lib/python2.7/dist-packages/pygame/docs/__init__.py
    ...
    /usr/lib/python2.7/dist-packages/pygame/docs/ref/camera.html
    ...
    /usr/lib/python2.7/dist-packages/pygame/docs/tut/DisplayModes.html
    ...
    /usr/lib/python2.7/dist-packages/pygame/examples/__init__.py
    ...
    /usr/lib/python2.7/dist-packages/pygame/examples/__init__.pyc
    ...
    /usr/lib/python2.7/dist-packages/pygame/examples/data/alien1.gif
    ...
    /usr/lib/python2.7/dist-packages/pygame/examples/macosx/aliens_app_example
    ...
    /usr/lib/python2.7/dist-packages/pygame/examples/macosx/aliens_app_example/English.lproj/MainMenu.nib/keyedobjects.nib
    /usr/lib/python2.7/dist-packages/pygame/gp2x/__init__.py
    ...
    /usr/lib/python2.7/dist-packages/pygame/tests/__init__.py
    ...
    /usr/lib/python2.7/dist-packages/pygame/tests/base_test.py
    ...
    /usr/lib/python2.7/dist-packages/pygame/threads/__init__.pyc
    /usr/share/bug/python-pygame
    ...
    /usr/share/doc/python-pygame
    ...
    many etceteras
    Last edited by b49P23TIvg; November 26th, 2012 at 01:42 PM.
    [code]Code tags[/code] are essential for python code and Makefiles!
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2009
    Posts
    492
    Rep Power
    33
    Install http://www.macports.org/ if you don't have it already. Then you can install with
    sudo port install py27-game
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Location
    Essex, England
    Posts
    4
    Rep Power
    0
    Great, I installed that. Not sure exactly what the last part of your instruction means however, or what it even is! Can you elaborate slightly?

    Thanks for your help.
  14. #8
  15. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,856
    Rep Power
    481
    Open a terminal window. (xterm, for example) Issue the command

    sudo port install py27-game

    If you don't know the secret root password you'll have to try something else.
    [code]Code tags[/code] are essential for python code and Makefiles!

IMN logo majestic logo threadwatch logo seochat tools logo