简体   繁体   中英

Trouble starting pygame on Mac OSX

I'm really beginner of computer and studying Python by myself. I installed python and pygame so that want to start this, however I got this error.

File "a.py", line 3, in <module>
    import pygame
  File "/Library/Python/2.7/site-packages/pygame/__init__.py", line 95, in <module>
    from pygame.base import *
ImportError: dlopen(/Library/Python/2.7/site-packages/pygame/base.so, 2): Library not loaded: @executable_path/../Frameworks/SDL.framework/Versions/A/SDL
  Referenced from: /Library/Python/2.7/site-packages/pygame/base.so
  Reason: unsafe use of @executable_path in /Library/Python/2.7/site-packages/pygame/base.so with restricted binary

How should I deal with this trouble ? Please teach me in detail. Thank you.

Firstly I note that you are learning Python. You might therefore not realise that there is a later version of Python - Python3. This will not in itself solve your problem but you might like to use the latest and start how you mean to go on.

There seems to be a problem with missing libraries in your case. I have not experienced this particular error but it might be worth you taking a look at this site https://pythonprogramming.net/pygame-python-3-part-1-intro/ where he talks about learning PyGame from a novice programmer's perspective. He uses python3 and tells you how to install, setup and develop with PyGame.

The python version picked is not the homebrew version. You can change the PATH environment variable in the shell that you are using.

In your case; just check the home brew installation and follow the suggested steps

brew doctor

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM