gpt4 book ai didi

python - 如何在 gitpod 中导入 pygame?

转载 作者:行者123 更新时间:2023-12-03 23:06:36 27 4
gpt4 key购买 nike

这是一个简单的 SudokuSolver 应用程序。

Project on 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'

你能帮我一下吗?感谢您。

最佳答案

在您的 .gitpod.yml you have configured the following init task :

$ pip3 install -r requirements.txt

打开 https://gitpod.io/#https://github.com/Deepak-dash007/SudokuVizualizationBacktracking 开始您的工作空间并在终端中运行此命令。您将获得以下输出:
$ pip3 install -r requirements.txt
Collecting pygame
Downloading pygame-1.9.6.tar.gz (3.2 MB)
|████████████████████████████████| 3.2 MB 6.8 MB/s
ERROR: Command errored out with exit status 1:
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
cwd: /tmp/pip-install-fgexue3e/pygame/
Complete output (12 lines):


WARNING, No "Setup" File Exists, Running "buildconfig/config.py"
Using UNIX configuration...

/bin/sh: 1: sdl-config: not found
/bin/sh: 1: sdl-config: not found
/bin/sh: 1: sdl-config: not found

Hunting dependencies...
WARNING: "sdl-config" failed!
Unable to run "sdl-config". Please make sure a development version of SDL is installed.
----------------------------------------
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/1364435

更改您的 image在您的 .gitpod.yml 中配置到:

image:
file: .gitpod.Dockerfile

并添加了一个新文件 .gitpod.Dockerfile安装其他 Stack Overflow 帖子中链接的依赖项:
FROM gitpod/workspace-full-vnc

RUN sudo apt-get update && sudo apt-get install -y \
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 工作区。就是这样。

你会在这里找到一个正在运行的仓库 https://github.com/corneliusludmann/SudokuVizualizationBacktracking

我还为您创建了一个拉取请求: https://github.com/Deepak-dash007/SudokuVizualizationBacktracking/pull/1

关于python - 如何在 gitpod 中导入 pygame?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62217095/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com