简体   繁体   English

Pycharm 中没有模块 pygame

[英]no module pygame in Pycharm

I try to work for the first time with Kivy, I install it but when I run the program I have this error message:我第一次尝试使用 Kivy,我安装了它,但是当我运行程序时,我收到以下错误消息: 在此处输入图片说明

And I try to install pygame, but I still have the same error:我尝试安装 pygame,但仍然出现相同的错误: 在此处输入图片说明

Any help please?请问有什么帮助吗?

To ensure proper setup, you can download pygame from PyCharm directly.为确保正确设置,您可以直接从 PyCharm 下载 pygame。

单击“+”按钮添加 PyGame 包

进入 PyGame 并按“安装包”

You should now be able to import pygame and use them in your scripts.您现在应该能够导入 pygame 并在您的脚本中使用它们。

For PyCharm, go to:对于 PyCharm,请转到:

  1. File文件
  2. Settings设置
  3. Project: Project_Name项目:Project_Name
  4. Click the '+' icon (located on the bottom side).单击“+”图标(位于底部)。 Then will Appear new window.然后会出现新窗口。
  5. Search pygame on this window在此窗口上搜索 pygame
  6. Then click 'Install Package'然后点击“安装包”
  7. close the window and run your code.关闭窗口并运行您的代码。

Most of the time it's due to not having the interpreter installed.大多数时候是因为没有安装解释器。

On terminal:在终端:

  • pip install pylint (to install globally) pip install pylint(全局安装)
  • Restart pycharm and click on install package "pygame" over the error it shows.重新启动 pycharm 并在它显示的错误上单击安装包“pygame”。 This also applies for most of the other packages.这也适用于大多数其他软件包。

If you are using VsCode or any other, just pip install pygame (or any other needed) and it should be working.如果您正在使用 VsCode 或任何其他,只需 pip install pygame(或任何其他需要的),它应该可以工作。

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

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