Python说它找不到Pygame

发布于 2025-02-05 09:23:03 字数 324 浏览 1 评论 0原文

在我的Python代码的顶部,我像往常一样将导入的Pygame放置,并在计算机上安装了该模块。那么,运行代码时为什么要得到这个呢?我已经尝试删除pygame并重新安装它,但它没有起作用。这些文件在我的计算机上。谁能帮我吗?

Traceback (most recent call last):
  File "C:\Users\<myuser>\Documents\RPG\main.py", line 1, in <module>
    import pygame
ModuleNotFoundError: No module named 'pygame'

At the top of my python code, I put import pygame as usual, and have installed the module on my computer. So why do i get this when running my code? I have already tried deleting pygame and reinstalling it and it has not worked. The files are on my computer. Can anyone help me?

Traceback (most recent call last):
  File "C:\Users\<myuser>\Documents\RPG\main.py", line 1, in <module>
    import pygame
ModuleNotFoundError: No module named 'pygame'

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风和你 2025-02-12 09:23:03

我认为,安装Python时可能不会添加Python路径。如果您使用的是Windows,请搜索编辑系统环境变量。单击环境变量,在“系统变量”部分中,双击路径 - 并添加Python软件的路径。
例如: C:\ Program Files \ Python310 \ scripts \&amp; C:\ Program Files \ Python310*

I think you might not have added the python path when you installed python. If you're using windows, search for Edit the system environment variables. Click on Environment variables, in the system variables section, double click on path -- and add the path of your python software.
ex: C:\Program Files\Python310\Scripts\ & C:\Program Files\Python310*

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文