简体   繁体   English

如何在 PyCharm 之外打开 pygame windows?

[英]How can I open pygame windows outside of PyCharm?

I made a game in pygame.我在pygame中做了一个游戏。 It works perfectly fine when run from pycharm.从 pycharm 运行时,它工作得非常好。 However, when I want to run it from another location, say command prompt or just windows explorer, all that I get is a black screen that briefly pops up before closing.但是,当我想从另一个位置运行它时,比如命令提示符或只是 windows 资源管理器,我得到的只是一个黑屏,在关闭前会短暂弹出。

I have had the same problems when writing code that uses selenium or other imports.在编写使用 selenium 或其他导入的代码时,我遇到了同样的问题。 I'm quite sure that the imports are the problem.我很确定进口是问题所在。 Code without imports works just fine, regardless from where it's run.没有导入的代码工作得很好,不管它在哪里运行。

I'm sorry if this is a stupid question with an obvious answer, I'm still a beginner.很抱歉,如果这是一个有明显答案的愚蠢问题,我仍然是初学者。 Thank you in advance, noble people of StackOverflow.提前感谢 StackOverflow 的高尚人士。

Try to run this command in cmd (outside the environment):尝试在 cmd(环境外)中运行此命令:

pip install pygame 

Mine works fine and, yes, it is a problem related to the imports.我的工作正常,是的,这是与进口有关的问题。

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

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