简体   繁体   English

PyGame 蛇游戏未在 PyCharm 中运行

[英]PyGame snake game not running in PyCharm

I am trying to run a python file for a snake game in PyCharm (Community Edition 2020.2).我正在尝试在 PyCharm(社区版 2020.2)中为蛇游戏运行 python 文件。 I am using Python 3.8.我正在使用 Python 3.8。 When I try to run the file, the Python application tries to open, but is never able to to start the game.当我尝试运行该文件时,Python 应用程序尝试打开,但永远无法启动游戏。 I feel like there is something wrong with my interpreter.我觉得我的翻译有问题。 I used the "which python3" command to figure out where my Python3 was installed and am using that location for my interpreter, but again, the application doesn't open upon running.我使用“which python3”命令来确定我的 Python3 的安装位置,并将该位置用于我的解释器,但同样,应用程序在运行时没有打开。 I have attached a screenshot of my interpreter.我附上了我的口译员的截图。 Any thoughts on what might be wrong would be great任何关于可能出错的想法都会很棒在此处输入图片说明

PyCharm automatically creates a virtual env for your work. PyCharm 会自动为您的工作创建一个虚拟环境。 That might be the root of your problem.这可能是你问题的根源。 You could look up about that to resolve your problem.你可以查一下这个来解决你的问题。 I am a bit less familar with virtual-envs.我对虚拟环境不太熟悉。 Someone else could give you detailed info but it might be the gist.其他人可以为您提供详细信息,但这可能是要点。

I found this:我找到了这个:

Yes, the assumption about the "virtual environment " is correct.是的,关于“虚拟环境”的假设是正确的。 The thing is that you are running the same script in different environments: in PyCharm it is a virtual environment configured for the project, in terminal it is anaconda environment (to know for sure, run > which python ).问题是您在不同的环境中运行相同的脚本:在 PyCharm 中它是为项目配置的虚拟环境,在终端中它是 anaconda 环境(要确定,运行 > which python )。

If you activated the virtual environment in the terminal and run the code, it would not display any picture.如果您在终端中激活虚拟环境并运行代码,它不会显示任何图片。 So, it confirms the issue is out of PyCharm scope.因此,它确认问题超出了 PyCharm 范围。 For some reason, the output cannot be displayed in the virtual environment.由于某种原因,无法在虚拟环境中显示输出。

However, as a workaround, you can create a Conda environment in PyCharm https://www.jetbrains.com/help/pycharm/conda-support-creating-conda-virtual-environment.html and use it instead of the current one.但是,作为一种解决方法,您可以在 PyCharm https://www.jetbrains.com/help/pycharm/conda-support-creating-conda-virtual-environment.html 中创建一个 Conda 环境并使用它而不是当前的环境。

Please let me know if there are any questions.如果有任何问题,请告诉我。

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

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