如何在gitpod中导入pygame?

这是一个简单的数独求解器应用程序。


GitHub 上的项目

它工作完美。但是当我尝试在 gitpod 中运行它时,它无法导入 pygame。


Error:

gitpod /workspace/SudokuVizualizationBacktracking $ /home/gitpod/.pyenv/versions/3.8.2/bin/python /workspace/SudokuVizualizationBacktracking/GUI.py

Traceback (most recent call last):

  File "/workspace/SudokuVizualizationBacktracking/GUI.py", line 1, in <module>

    import pygame

ModuleNotFoundError: No module named 'pygame'

你能帮帮我吗?感谢您。


不负相思意
浏览 111回答 1
1回答

UYOU

在您.gitpod.yml&nbsp;的配置中,您配置了以下初始化任务:$&nbsp;pip3&nbsp;install&nbsp;-r&nbsp;requirements.txt通过打开https://gitpod.io/#https://github.com/Deepak-dash007/SudokuVizualizationBacktracking启动您的工作区,并在终端中运行此命令。您将获得以下输出:$ pip3 install -r requirements.txtCollecting pygame&nbsp; Downloading pygame-1.9.6.tar.gz (3.2 MB)&nbsp; &nbsp; &nbsp;|████████████████████████████████| 3.2 MB 6.8 MB/s&nbsp;&nbsp; &nbsp; ERROR: Command errored out with exit status 1:&nbsp; &nbsp; &nbsp;command: /home/gitpod/.pyenv/versions/3.8.2/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-fgexue3e/pygame/setup.py'"'"'; __file__='"'"'/tmp/pip-install-fgexue3e/pygame/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-9lyba20o&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cwd: /tmp/pip-install-fgexue3e/pygame/&nbsp; &nbsp; Complete output (12 lines):&nbsp; &nbsp; WARNING, No "Setup" File Exists, Running "buildconfig/config.py"&nbsp; &nbsp; Using UNIX configuration...&nbsp; &nbsp; /bin/sh: 1: sdl-config: not found&nbsp; &nbsp; /bin/sh: 1: sdl-config: not found&nbsp; &nbsp; /bin/sh: 1: sdl-config: not found&nbsp; &nbsp; Hunting dependencies...&nbsp; &nbsp; WARNING: "sdl-config" failed!&nbsp; &nbsp; Unable to run "sdl-config". Please make sure a development version of SDL is installed.&nbsp; &nbsp; ----------------------------------------ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.在这里你可以看到它sdl-config丢失了。Google 找到了这个 Stack Overflow 答案,其中列出了所需的依赖项pygame:https ://stackoverflow.com/a/60990677/1364435image将您的配置更改.gitpod.yml为:image:&nbsp; file: .gitpod.Dockerfile并添加了一个新文件.gitpod.Dockerfile,用于安装其他 Stack Overflow 帖子中链接的依赖项:FROM gitpod/workspace-full-vncRUN sudo apt-get update && sudo apt-get install -y \&nbsp; &nbsp; python-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev libsdl1.2-dev libsmpeg-dev python-numpy subversion libportmidi-dev ffmpeg libswscale-dev libavformat-dev libavcodec-dev推送所有内容并创建一个新的 Gitpod 工作区。而已。你会在这里找到一个正在运行的 repo&nbsp;https://github.com/corneliusludmann/SudokuVizualizationBacktracking我还为您创建了一个 Pull Request:https ://github.com/Deepak-dash007/SudokuVizualizationBacktracking/pull/1
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python