How do I download Pygame for Python 3.5.1?

前端 未结 6 1595
醉梦人生
醉梦人生 2021-01-18 09:06

I am unable to find a pygame download for Python 3.5 and the ones I have downloaded don\'t seem to work when I import to the shell. Help?

This is the message I recei

相关标签:
6条回答
  • 2021-01-18 09:23

    For windows now you simply use pip as it's available directly to install as pygame.

    Use the following command:

    python -m pip install pygame
    

    It should output something like this, then you can test if it's working by importing pygame.

    PS C:\Windows\system32> python -m pip install pygame
    Collecting pygame
      Downloading pygame-1.9.2b1-cp35-cp35m-win32.whl (4.4MB)
      100% |################################| 4.4MB 264kB/s
    Installing collected packages: pygame
    Successfully installed pygame-1.9.2b1
    PS C:\Windows\system32> python
    Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:01:18) [MSC v.1900 32 bit (Intel)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import pygame
    # Note there is no error here...
    >>> quit()
    PS C:\Windows\system32>
    
    0 讨论(0)
  • 2021-01-18 09:24

    Even when you have windows 64 bit you need to get the win32.whl file , then follow the standard instructions

    0 讨论(0)
  • 2021-01-18 09:32

    In an anaconda environment with python 3.5 installed, you can simply do:

    pip install pygame

    $pip install pygame
    Collecting pygame
      Downloading pygame-1.9.3-cp35-cp35m-manylinux1_x86_64.whl (9.4MB)
        100% |***************************| 9.4MB 132kB/s 
    Installing collected packages: pygame
    Successfully installed pygame-1.9.3
    

    I'm in ubuntu 14.04, this should work with newer and other linuxes.

    0 讨论(0)
  • 2021-01-18 09:37

    This worked preety well for me:

    System: Ubuntu 16.10 x64

    root@sonic-VirtualBox:~/python# cat /etc/*-release
    DISTRIB_ID=Ubuntu
    DISTRIB_RELEASE=16.10
    DISTRIB_CODENAME=yakkety
    DISTRIB_DESCRIPTION="Ubuntu 16.10"
    NAME="Ubuntu"
    VERSION="16.10 (Yakkety Yak)"
    ID=ubuntu
    ID_LIKE=debian
    PRETTY_NAME="Ubuntu 16.10"
    VERSION_ID="16.10"
    HOME_URL="http://www.ubuntu.com/"
    SUPPORT_URL="http://help.ubuntu.com/"
    BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
    PRIVACY_POLICY_URL="http://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
    VERSION_CODENAME=yakkety
    UBUNTU_CODENAME=yakkety
    root@sonic-VirtualBox:~/python# 
    

    Python 2.7 + Pygame:

    root@sonic-VirtualBox:~/python# python -V
    Python 2.7.12+
    # apt-get install python-pip
    # pip install --upgrade pip
    # pip install pygame
    

    Python 3.5 + Pygame: (Python 3.5.2+ in my case)

    root@sonic-VirtualBox:~/python# python3 -V
    Python 3.5.2+
    
    # sudo apt-get install python3-pip
    # pip3 install --upgrade pip
    # pip3 install pygame
    
    0 讨论(0)
  • 2021-01-18 09:40

    Download to pygame3.5

    Then put this into your cmd

    cd [location of python3.5]
    python -m pip install [location of pygame]
    python -m pip install --upgrade pip
    

    Then type

    import pygame
    pygame.init()
    
    0 讨论(0)
  • 2021-01-18 09:45

    I'm gonna guess your using Windows. If you are not then there is no special version of pygame for Python 3+. If you do have Windows then read below.

    You will need pygame to be part of your path to do this. This is so you can use this in the command prompt. Make sure you use it as an admin when doing this.

    First you need to find out what bit version of Python you have. Open your Python shell and at the top of the window it should say something like "Pygame V(some number) (bit number)" You want the bit number.

    Now you ned to open the command prompt. Use the "windows key + r key" to open the run menu, and type "cmd" and press enter. Or you can just search your PC for "cmd" and right click on it and select "run as admin" to open as an admin.

    Python comes with a special path command called "pip." I am not gonna get into this module too much, but in short it is used to install addition Python modules. The first thing you need to do is this command...

    pip install wheel
    

    The screen should print some stuff off while doing this. You can tell if the module installed correctly because it should print something like "wheel installed successfully." We are gonna need this later.

    Now you need to get your pygame file. Go here and find the pygame section. If you have python 32 bit download you should download this "pygame-1.9.2b1-cp35-cp35m-win32.whl" or if you have 64 bit Python download "pygame-1.9.2b1-cp35-cp35m-win_amd64.whl". I am pretty sure these are the ones you need for your bit version, but I installed pygame on my Windows 10 a few months ago so they may be different now.

    Once you have this downloaded go back to the command prompt. Enter this command...

    pip install (filename)
    

    Make sure it includes the .whl extension. If you get an error then specify the path to the folder the file is in (which should be the downloads folder). Once again you should see a message similar to "pygame installed successfully."

    Once all this is done open your Python shell and type...

    import pygame
    

    If it works you now have pygame available for use. If not then there are a few more things you can try...

    1. Try restarting your PC. Sometimes these things don't take affect until a system restart.
    2. Try installing a different version of pygame from the website listed above. It may just be a simple issue due to bit version differences.
    3. Make sure you actually installed the pygame module from the file. It may of thrown an error that appeared to be an actual successful installation. It always pays to double-check.

    Like I said before I installed pygame on my Windows 10 with Python 3.4 64 bit a few months ago in the same way I told you here so it should work, but may be outdated. Anyways I hope this helps you with your pygame installation issues and the best of luck to you!

    0 讨论(0)
提交回复
热议问题