This article mainly introduces the detailed Python pygameInstallation process notes. The editor thinks it’s pretty good, so I’d like to share it with you now and give it as a reference. Let’s follow the editor and take a look
Today I saw a tutorial about installing the pygame module in Python. I think it’s good, so I’ll share it.
Installing Python
Well, this question seems to be superfluous here. But in order to take care of children who have just learned Python, I will say a few more words.
The details are as follows:
We need to go to the Python official website. Go download the version we need. What I downloaded here is Python2.7 msi for windows 64 bit. If you don’t understand the installation process, just choose the default.
Install easy_install
As for what this is? We don't have to worry about it, now we just need to know that it can help us install some libraries. The specific installation process is also very simple. You only need to download the library and install it using python commands.
Install pip
Okay, after going through the first two steps, everyone (especially those who are just getting started) will definitely be very upset. Why do you need to pack so many things? But don't lose heart, because good times are coming soon. pip is such an artifact that can free you from the complex labor of installing libraries. Let’s take a look at how to install pip.
Before this, be sure to confirm that Python and easy_install have been installed in your windows system.
Signs of successful installation:
Microsoft Windows [版本 6.1.7600] 版权所有 (c) 2009 Microsoft Corporation。保留所有权利。 C:\Users\Administrator>python Python 2.7.11 (v2.7.11:6d1b6a68f775, Dec 5 2015, 20:40:30) [MSC v.1500 64 bit ( AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> exit() C:\Users\Administrator>easy_install -version usage: easy_install [options] requirement_or_url ... or: easy_install --help error: option -r not recognized C:\Users\Administrator>
The next step is to switch the directory to the Script folder in the python installation directory and enter
easy_install pip. Of course, if you want to make it more convenient, you can configure this path into your environment variable (as for how to configure it, there are many related tutorials on the Internet that are very detailed. I will not reinvent the wheel).
Verify:
C:\Users\Administrator>pip -v Usage: pip <command> [options] Commands: install Install packages. download Download packages. uninstall Uninstall packages. freeze Output installed packages in requirements format. list List installed packages. show Show information about installed packages. search Search PyPI for packages. wheel Build wheels from your requirements. hash Compute hashes of package archives. completion A helper command used for command completion help Show help for commands. General Options: -h, --help Show help. --isolated Run pip in an isolated mode, ignoring environment variables and user configuration. -v, --verbose Give more output. Option is additive, and can be used up to 3 times. -V, --version Show version and exit. -q, --quiet Give less output. --log <path> Path to a verbose appending log. --proxy <proxy> Specify a proxy in the form [user:passwd@]proxy.server:port. --retries <retries> Maximum number of retries each connection should attempt (default 5 times). --timeout <sec> Set the socket timeout (default 15 seconds). --exists-action <action> Default action when a path already exists: (s)witch, (i)gnore, (w)ipe, (b)ackup. --trusted-host <hostname> Mark this host as trusted, even though it does not have valid or any HTTPS. --cert <path> Path to alternate CA bundle. --client-cert <path> Path to SSL client certificate, a single file containing the private key and the certificate in PEM format. --cache-dir <dir> Store the cache data in <dir>. --no-cache-dir Disable the cache. --disable-pip-version-check Don't periodically check PyPI to determine whether a new version of pip is available for download. Implied with --no-index. C:\Users\Administrator>
Install pygame
The prerequisite for installing pygame is that you must first download this File. So we need to download it. pygame File download. Remember to download it corresponding to your Python version.
After downloading, we will find that it is a file with a .whl suffix. This is more embarrassing. How to open it?
The answer is to use another tool, wheel. Wheel is essentially a zip package format that uses the .whl extension for the installation of python modules. It appears to replace Eggs. wheel also provides a bdist_wheel as an extension command of setuptools, which can be used to generate wheel packages. Wheel it to check whether the installation is successful.
The way to install wheel is much more fun this time. Because we already have pip.
pip install wheel
. nailed it.
Now go back and enter the directory of pygameXXXXX.whl, wheel file name. Okay, it’s completely done.
Verify that
C:\Users\Administrator>python Python 2.7.11 (v2.7.11:6d1b6a68f775, Dec 5 2015, 20:40:30) [MSC v.1500 64 bit ( AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import pygame >>>
No error is reported, which means that the installation was successful. Let’s start a pleasant pygame journey.
Summary
The overall installation process is very confusing. Especially for those who are just starting out. However, this is also the most valuable experience. Because the installation of these libraries will make you more familiar with Python's architecture. The grasp of the overall structure will also be better.
The above is the detailed content of How to install Python pygame? Detailed tutorial examples of Python pygame installation. For more information, please follow other related articles on the PHP Chinese website!