简体   繁体   English

当我尝试为Python 3.6安装Pygame时,Pip无法正常工作[已过时]

[英]Pip not working when I try to install Pygame for Python 3.6 [Outdated]

I am using windows 10 home edition 64-bit edition. 我正在使用Windows 10家庭版64位版本。 I am using python 3.6 64-bit edition. 我正在使用python 3.6 64位版本。 I have tried to solve the error by running a clean install of python but that didn't solve the problem. 我已经尝试通过运行python的全新安装来解决此错误,但这并不能解决问题。

I tried to install pygame via pip, but the following results were produced: 我尝试通过pip安装pygame,但产生了以下结果:

    C:\Windows\system32>pip install pygame
    Collecting pygame
      Using cached pygame-1.9.2.tar.gz
        Complete output from command python setup.py egg_info:


    WARNING, No "Setup" File Exists, Running "config.py"
    Using WINDOWS configuration...

    Path for SDL not found.
    Too bad that is a requirement! Hand-fix the "Setup"
    Path for FONT not found.
    Path for IMAGE not found.
    Path for MIXER not found.
    Path for PNG not found.
    Path for JPEG not found.
    Path for PORTMIDI not found.
    Path for COPYLIB_tiff not found.
    Path for COPYLIB_z not found.
    Path for COPYLIB_vorbis not found.
    Path for COPYLIB_ogg not found.

    If you get compiler errors during install, doublecheck
    the compiler flags in the "Setup" file.


    Continuing With "setup.py"
    Error with the "Setup" file,
    perhaps make a clean copy from "Setup.in".
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\*****~1\AppData\Local\Temp\pip-build-ciac4jty\pygame\setup.py", line 165, in <module>
        extensions = read_setup_file('Setup')
      File "c:\program files\python36\lib\distutils\extension.py", line 171, in read_setup_file
        line = expand_makefile_vars(line, vars)
      File "c:\program files\python36\lib\distutils\sysconfig.py", line 410, in expand_makefile_vars
        s = s[0:beg] + vars.get(m.group(1)) + s[end:]
    TypeError: must be str, not NoneType

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\*****~1\AppData\Local\Temp\pip-build-ciac4jty\pygame\

What caused this error? 是什么导致此错误? How do I solve it? 我该如何解决?

pygame isn't (officially) compatible with Python 3.6 yet(Jan 5, 2017). pygame目前尚未(正式)与Python 3.6兼容(2017年1月5日)。 Try a lower version of Python like 3.5.2 尝试使用较低版本的Python,例如3.5.2

I had the same problem as you. 我和你有同样的问题。

Setup 设定

Go to this page: http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame and download the .whl file that suits your Python and Windows version. 转到此页面: http : .whl并下载适合您的Python Windows版本的.whl文件。

In my case it's pygame‑1.9.2‑cp36‑cp36m‑win_amd64.whl since I use Python 3.6.0 and Windows 64-bit . 就我而言,它是pygame‑1.9.2‑cp36‑cp36m‑win_amd64.whl因为我使用的是Python 3.6.0Windows 64位

Next, enter cmd in the search box on your taskbar and press enter. 接下来,在任务栏上的搜索框中输入cmd ,然后按Enter。 A command window will open. 将打开一个命令窗口。

Enter the following into the cmd : cmd输入以下内容:

pip install setuptools
pip install wheel
pip install --upgrade setuptools
pip install --upgrade wheel

You then have two options when installing pygame : 然后,在安装pygame时有两个选择:

Option 1 - In Python Folder 选项1-在Python资料夹中

Paste the file you downloaded earlier in the Python folder ( in my case it's C:\\Python ). 将您先前下载的文件粘贴到Python文件夹中( 在我的情况下为 C:\\Python )。

If you downloaded pygame‑1.9.2‑cp36‑cp36m‑win_amd64.whl , install pygame with: 如果您下载了pygame‑1.9.2‑cp36‑cp36m‑win_amd64.whl ,请使用以下pygame‑1.9.2‑cp36‑cp36m‑win_amd64.whl安装pygame

pip install pygame‑1.9.2‑cp36‑cp36m‑win_amd64.whl

(Or else change pygame‑1.9.2‑cp36‑cp36m‑win_amd64.whl to the name of the file you downloaded, if it is different to mine). (或者将pygame‑1.9.2‑cp36‑cp36m‑win_amd64.whl为您下载的文件的名称(如果与我的名称不同))。

Before you enter the previous command, make sure the file you downloaded is in the Python folder ( in my case, C:\\Python\\pygame‑1.9.2‑cp36‑cp36m‑win_amd64.whl ) and you copied the whole file name including the .whl extension or else it won't work. 在输入上C:\\Python\\pygame‑1.9.2‑cp36‑cp36m‑win_amd64.whl命令之前,请确保下载的文件位于Python文件夹中( 在我的情况下为 C:\\Python\\pygame‑1.9.2‑cp36‑cp36m‑win_amd64.whl ),并复制了整个文件名,包括.whl扩展名,否则它将不起作用。

Option 2 - On Desktop 选项2-在桌面上

Paste the file you downloaded earlier on your desktop. 将您先前下载的文件粘贴到桌面上。

If you placed your .whl file on your desktop, enter this to change your current directory: 如果您将.whl文件放在桌面上,请输入以下文件来更改当前目录:

cd "C:\Users\(your_username)\Desktop"

Then, if you downloaded pygame‑1.9.2‑cp36‑cp36m‑win_amd64.whl , install pygame with: 然后,如果您下载了pygame‑1.9.2‑cp36‑cp36m‑win_amd64.whl ,请使用以下pygame‑1.9.2‑cp36‑cp36m‑win_amd64.whl安装pygame

pip install pygame‑1.9.2‑cp36‑cp36m‑win_amd64.whl

(Or else change pygame‑1.9.2‑cp36‑cp36m‑win_amd64.whl to the name of the file you downloaded, if it is different to mine). (或者将pygame‑1.9.2‑cp36‑cp36m‑win_amd64.whl为您下载的文件的名称(如果与我的名称不同))。

Before you enter the previous command, make sure you change your current directory and you copied the whole file name including the .whl extension or else it won't work 在输入上一个命令之前,请确保更改了当前目录,并且复制了整个文件名(包括.whl扩展名),否则它将不起作用

This should install pygame 1.9.2 and work on Python 3.6.0. 这应该安装pygame 1.9.2并在Python 3.6.0上工作。

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

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