简体   繁体   English

安装 Python 模块 Pygame 和 Pygame Zero 导致的错误

[英]Errors by installing Python modules Pygame and Pygame Zero

I've succesfully installed Python version 3.8.1 and also PIP.我已经成功安装了 Python 3.8.1 版和 PIP。

After that i want to install Pygame and Pygame Zero with the commands pip install pygame or pip install pgzero之后我想使用命令 pip install pygame 或 pip install pgzero 安装 Pygame 和 Pygame Zero

But I get the following error:但我收到以下错误:

C:>pip install pygame Traceback (most recent call last): File "c:\\program files\\python38\\lib\\runpy.py", line 193, in _run_module_as_main return _run_code(code, main_globals, None, File "c:\\program files\\python38\\lib\\runpy.py", line 86, in _run_code exec(code, run_globals) File "C:\\Program Files\\Python38\\Scripts\\pip.exe__main__.py", line 9, in TypeError: 'module' object is not callable C:>pip install pygame Traceback(最近一次调用最后一次):文件“c:\\program files\\python38\\lib\\runpy.py”,第 193 行,在 _run_module_as_main 中 return _run_code(code, main_globals, None, File "c:\\ program files\\python38\\lib\\runpy.py”,第 86 行,在 _run_code exec(code, run_globals) 文件“C:\\Program Files\\Python38\\Scripts\\pip.exe__main__.py”,第 9 行,在 TypeError: 'module ' 对象不可调用

Also with the --user command it doesn't succeed: pip install pygame --user or pip install pgzero --user同样使用 --user 命令它不会成功: pip install pygame --user 或 pip install pgzero --user

What am I doing w我在做什么 w

I also got that problem long ago.我很久以前也遇到过这个问题。

You can try this:你可以试试这个:

pip uninstall pygame
pip uninstall pgzrun

then download it by:然后通过以下方式下载:

pip install pygame
pip install pgzrun

Info of your assets are little low.. But if you have Python 2 and 3, try manage your alias on CMD by checking your current python variables from /usr/bin and from CMD type "python --version" to see current default.您的资产信息有点低。但是如果您有 Python 2 和 3,请尝试通过从 /usr/bin 和 CMD 类型“python --version”检查当前 python 变量来查看当前默认值来管理 CMD 上的别名。 If it says Python2.7 you can chance that with "alias" command below (reason to do that, is 2.7 support is ending 1.1.2020 and old pip for it too. So in future, you should upload new modules just for Python3.7).如果它说 Python2.7,您可以使用下面的“别名”命令(这样做的原因是 2.7 支持即将结束 2020 年 1 月 1 日,并且它的旧 pip 也是如此。因此,将来,您应该只为 Python3 上传新模块。 7)。 If you have 2.7 in your PC and you have been using it for some time, you should not try to remove it.如果您的 PC 中有 2.7 并且已经使用了一段时间,则不应尝试将其删除。

So just in case: $ alias python="/usr/bin/python3.7"所以以防万一: $ alias python="/usr/bin/python3.7"

Then use command然后使用命令

$ sudo pip3 install pygame $ sudo pip3 安装 pygame

This should work.这应该有效。 If not, there is some setting problems on your module site.如果没有,则您的模块站点上存在一些设置问题。

Give a hit with this and if it doesn't work, let us know.试试这个,如果它不起作用,请告诉我们。 I can give instruction to get it to work.我可以给出指令让它工作。 It requires few steps at (in my case:)它需要几个步骤(在我的情况下:)

/home/usr/Python-3.7.4/Modules/Settings. /home/usr/Python-3.7.4/Modules/Settings.

It can (I'm not sure with these modules but..) require to set SSL connection too, but it can be done from there too, without any coding.它可以(我不确定这些模块,但是..)也需要设置 SSL 连接,但它也可以从那里完成,无需任何编码。

Thank you for the quick arswers!感谢您的快速回答! It is succeeded by giving the commands: py -3 -m pip install pygame --user py -3 -m pip install pgzero --user通过给出命令成功: py -3 -m pip install pygame --user py -3 -m pip install pgzero --user

The only warnings i got by installing pgzero were:我通过安装 pgzero 得到的唯一警告是:

Collecting pgzero Downloading ..... Installing collected packages: numpy, pgzero WARNING: The script f2py.exe is installed in 'C:\\Users\\Han\\AppData\\Roaming\\Python\\Python38\\Scripts' which is not on PATH.正在收集 pgzero 正在下载 ..... 正在安装收集的软件包:numpy、pgzero 警告:脚本 f2py.exe 安装在不在 PATH 上的“C:\\Users\\Han\\AppData\\Roaming\\Python\\Python38\\Scripts”中。 Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.考虑将此目录添加到 PATH,或者,如果您希望取消此警告,请使用 --no-warn-script-location。 WARNING: The script pgzrun.exe is installed in 'C:\\Users\\Han\\AppData\\Roaming\\Python\\Python38\\Scripts' which is not on PATH.警告:脚本 pgzrun.exe 安装在不在 PATH 上的“C:\\Users\\Han\\AppData\\Roaming\\Python\\Python38\\Scripts”中。 Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.考虑将此目录添加到 PATH,或者,如果您希望取消此警告,请使用 --no-warn-script-location。 Successfully installed numpy-1.18.0 pgzero-1.2成功安装 numpy-1.18.0 pgzero-1.2

Oh.. I didn't know, you are using Windows.. My last answer dried down with that.哦.. 我不知道,您使用的是 Windows.. 我的最后一个答案就此枯竭。 It was for Linux.它适用于 Linux。 Either way, when you installed python, did you mark the PATH in installation process?无论哪种方式,当您安装python时,您是否在安装过程中标记了PATH? It shows when installation windows pops up.它显示安装窗口何时弹出。 I'm little noob with windows, but I expect it to be as same as in any operation systems.我对 Windows 是个小菜鸟,但我希望它与任何操作系统中的一样。 If you didn't, its easier to remove Python and install it again, than try to mark the PATH after installing.如果没有,删除 Python 并重新安装它比在安装后尝试标记 PATH 更容易。 After all its just 1/2 min job.毕竟它只是 1/2 分钟的工作。

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

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