如何在gitpod中导入pygame?

迪帕克破折号

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

在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 您配置了以下初始化任务

$ 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答案,其中列出了以下内容所需的依赖项pygamehttps : //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

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章