简体   繁体   English

在Mac OSX上启动pygame出现问题

[英]Trouble starting pygame on Mac OSX

I'm really beginner of computer and studying Python by myself. 我真的是计算机的新手,自己一个人学习Python。 I installed python and pygame so that want to start this, however I got this error. 我安装了python和pygame,所以想启动它,但是出现了这个错误。

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. 首先,我注意到您正在学习Python。 You might therefore not realise that there is a later version of Python - Python3. 因此,您可能没有意识到存在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. 我没有遇到这个特定的错误,但是您值得一看这个站点https://pythonprogramming.net/pygame-python-3-part-1-intro/他从新手程序员的角度谈论学习PyGame。 。 He uses python3 and tells you how to install, setup and develop with PyGame. 他使用python3并告诉您如何使用PyGame进行安装,设置和开发。

The python version picked is not the homebrew version. 选择的python版本不是自制版本。 You can change the PATH environment variable in the shell that you are using. 您可以在使用的外壳中更改PATH环境变量。

In your case; 就你而言 just check the home brew installation and follow the suggested steps 只需检查家用冲煮器的安装并按照建议的步骤进行操作

brew doctor

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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