简体   繁体   English

我无法导入pygame

[英]I can't import pygame

import pygame

My code is not working. 我的代码无法正常工作。 I have downloaded pygame for python 2.7. 我已经为python 2.7下载了pygame。 Most pages I looked at, recommended reinstalling python, pygame or both.I did this and it did't work. 我浏览过的大多数页面都建议重新安装python,pygame或同时重新安装python.py,但是没有用。 Also people recommended changing the system from 32 bit to 64 bit or the other way around. 人们还建议将系统从32位更改为64位或以其他方式更改。 I did that to. 我是这么做的。 I tried this: 我尝试了这个:

import platform
platform.architecture()
import pygame

I even tried this all in python 3.5 but I keep getting the same error. 我什至在python 3.5中尝试了所有这些,但是我一直收到相同的错误。

Traceback (most recent call last): File "", line 1, in File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site- >>packages/pygame/ init .py", line 95, in from pygame.base import * ImportError: >>dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site->>packages/pygame/base.so, 2): no suitable image found. 追溯(最近一次通话最近):文件“ /”、“Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site- >> packages / pygame / init .py”中的文件“”,第1行,第95行,从pygame.base导入* ImportError:>> dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site->> packages / pygame / base.so,2):找不到合适的图像。 Did find: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site->>packages/pygame/base.so: no matching architecture in universal wrapper 确实找到了:/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site->>packages/pygame/base.so:通用包装中没有匹配的体系结构

or sometimes this: 或有时这样:

File "/Users/yulianasameroynina/Documents/python programs/gaming.py", line 3, in >> import pygame ImportError: No module named 'pygame' >>导入pygame中的文件“ / Users / yulianasameroynina / Documents / python program / gaming.py”,第3行,导入错误:没有名为“ pygame”的模块

when I use Pycharm, otherwise I get the first error weather I use Pydev or IDLE. 当我使用Pycharm时,否则我遇到的第一个错误天气是使用Pydev或IDLE。

Thanks 谢谢

This looks like you are just using an old version of pygame. 看来您只是在使用旧版本的pygame。 Try uninstalling the one you have now, and reinstalling it using pip. 尝试卸载您现在拥有的一个,然后使用pip重新安装它。 As to the ImportError Pycharm is giving you, this is just because Pycharm doesn't have the right sys.path , which you might be able to change in settings. 至于ImportError Pycharm给您的,这仅仅是因为Pycharm没有正确的sys.path ,您可能可以更改设置。

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

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