所以我正在做一个python项目,我必须在其中进行单击和拖动部分。所以我正在使用pygame。到目前为止,我尝试了pip install pygame和sudo apt install pygame,但我得到了以下错误。
错误:退出状态为1的命令出错:命令: /usr/bin/python3-c'import sys, setuptools,token enize;sys.argv[0] = '"'"'/tmp/pip-install-b36hmuvw/pygame/setup.py'"'"'; 文件='"'"'/tmp/pip-install-b36hmuvw/pygame/setup.py'"";f=getattr(token enize, '"'"'打开'"'"', 打开)(file);code=f.read()('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(编译(代码,文件, '"'"'exec'"'"'))' egg_info--ege-base /tmp/pip-pip-egg-info-l96tsf_2cwd: /tmp/pip-install-b36hmuvw/pygame/完整输出(29行):
WARNING, No "Setup" File Exists, Running "buildconfig/config.py"
Using UNIX configuration...
/bin/sh: 1: sdl2-config: not found
/bin/sh: 1: sdl2-config: not found
/bin/sh: 1: sdl2-config: not found
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-b36hmuvw/pygame/setup.py", line 318, in <module>
buildconfig.config.main(AUTO_CONFIG)
File "/tmp/pip-install-b36hmuvw/pygame/buildconfig/config.py", line 221, in main
deps = CFG.main(**kwds)
File "/tmp/pip-install-b36hmuvw/pygame/buildconfig/config_unix.py", line 194, in main
DependencyProg('SDL', 'SDL_CONFIG', 'sdl2-config', '2.0', ['sdl']),
File "/tmp/pip-install-b36hmuvw/pygame/buildconfig/config_unix.py", line 39, in __init__
self.ver = config[0].strip()
IndexError: list index out of range
Hunting dependencies...
---
For help with compilation see:
https://www.pygame.org/wiki/Compilation
To contribute to pygame development see:
https://www.pygame.org/contribute.html
---
----------------------------------------
错误:退出状态为1的命令错误:pythonsetup.pyegg_info检查日志以获取完整的命令输出。
我是python新手,不知道如何解决这个问题。
您可以使用“sudo apt install python-pygame”安装它,但如果您打开“python3.7”、“python2.7”等并输入“import pygame”,则会出现:
SyntaxError: invalid syntax
>>> import pygame
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'pygame'
但是,如果您使用命令“python”从终端打开python,则命令“import pygame”有效,但您使用pip安装的所有其他东西都无效。我希望我能帮助你:D
友好的问候Kolpix