Python:为每个新项目安装Pygame
我遇到了一些PIP安装问题。我找到了一种有效的安装方法,但我觉得这是错误的。
我从CMD提示符中安装了Pygame,并收到了此消息:
默认为用户安装,因为普通站点包不是 已满足的可写要求:pygame C:\ Users \ somenewguy \ appdata \ roaming \ python \ python310 \ site-packages (2.1.2)
但是,当我去Pycharm启动项目时,我收到了此消息:
Traceback (most recent call last):
File "C:\Users\Somenewguy\Python Projects\new\main.py", line 1, in <module>
import pygame
ModuleNotFoundError: No module named 'pygame'
然后,我从Pycharm的终端进行了Pygame Pip安装。但是这次我将其直接安装到项目文件夹中,并且该方法奏效了。 这是我可以将Pygame导入我认为很奇怪的项目的唯一方法。
为什么我必须为每个项目安装此软件包?
I ran into some problems with some pip installations. I have found a way of installing that works, but I feel like it's wrong.
I installed pygame from the cmd prompt and got this message:
Defaulting to user installation because normal site-packages is not writeable Requirement already satisfied: pygame in c:\users\Somenewguy\appdata\roaming\python\python310\site-packages (2.1.2)
But when I went to pycharm and started my project, I got this message:
Traceback (most recent call last):
File "C:\Users\Somenewguy\Python Projects\new\main.py", line 1, in <module>
import pygame
ModuleNotFoundError: No module named 'pygame'
I then did the pygame pip installation from the terminal in pycharm. But this time I installed it directly into the project folder, and that approach worked.
This is the only way I can import pygame into my projects which I think is weird.
Why do I have to install this package for each project?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您使用 virtual-environment 这是预期的,这是预期的行为。如果您不想每次安装它,请使用系统环境。
If you use a virtual-environment, this is the expected behavior. If you don't want to install it every time, use the system environnement.