詳解Python pygame安裝過程筆記,pythonpygame

來源:互聯網
上載者:User

詳解Python pygame安裝過程筆記,pythonpygame

今天看到一個教程,是關於Python安裝pygame模組的。覺得很好,拿來分享一下。

安裝Python

額,這個小題貌似在這裡很是多餘啊。但是為了照顧到剛剛學習Python的童鞋,我還是多囉嗦兩句吧。

具體如下:

我們要到Python官網。去下載我們需要的版本。我這裡下載的是windows64位 的Python2.7 msi。安裝的過程如果不懂,選擇為預設即可。

安裝easy_install

至於這是個什麼東東?我們大可不必勞心,現在只需要知道它能協助我們安裝一些庫就可以了。具體的安裝過程也很簡單,只需要下載這個庫,使用python的命令進行安裝即可。

安裝pip

好了,經過了前面的兩步,想必大家(尤其是剛入門的童鞋)肯定會很心煩了吧,怎麼需要裝這麼多的東西。但是咧,千萬不要灰心,因為好日子馬上就要來了。pip就是這麼一款能解放你安裝庫的複雜勞動的一款神器。下面就一起來看一看怎麼安裝pip吧。

在此之前,一定要確認你的windows系統中已經安裝好了Python和easy_install。

安裝成功的標誌:

Microsoft Windows [版本 6.1.7600]著作權 (c) 2009 Microsoft Corporation。著作權所有,並保留一切權利。C:\Users\Administrator>pythonPython 2.7.11 (v2.7.11:6d1b6a68f775, Dec 5 2015, 20:40:30) [MSC v.1500 64 bit (AMD64)] on win32Type "help", "copyright", "credits" or "license" for more information.>>> exit()C:\Users\Administrator>easy_install -versionusage: easy_install [options] requirement_or_url ...  or: easy_install --helperror: option -r not recognizedC:\Users\Administrator>

接下來就是把目錄切換到python的安裝目錄下的Script檔案夾下,輸入
easy_install pip。當然了如果要想方便一些的話,可以把這個路徑配置到你的環境變數中(至於怎麼配,網上的相關教程很多也很詳細。我就不重複的造輪子了)。

驗證一下:

C:\Users\Administrator>pip -vUsage: 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>

安裝pygame

安裝pygame的前提那肯定是先得下載這個檔案啊。所以我們需要下載一下。pygame 檔案下載。記得對應你的Python版本進行下載哦。

下載完之後我們會發現它是一個.whl尾碼的檔案。這就比較尷尬了。怎麼開啟呢?

答案就是使用另一款工具,wheel。wheel 本質上是一個 zip 包格式,它使用 .whl 副檔名,用於 python 模組的安裝,它的出現是為了替代 Eggs。wheel 還提供了一個 bdist_wheel 作為 setuptools 的擴充命令,這個命令可以用來產生 wheel 包。wheel一下,檢查是否安裝成功。

安裝wheel的方式這次就爽多了。因為我們已經有了pip。

pip install wheel。搞定了。

現在回過頭來進到pygameXXXXX.whl的目錄下,wheel 檔案名稱 .好了,徹底搞定了。

驗證一下

C:\Users\Administrator>pythonPython 2.7.11 (v2.7.11:6d1b6a68f775, Dec 5 2015, 20:40:30) [MSC v.1500 64 bit (AMD64)] on win32Type "help", "copyright", "credits" or "license" for more information.>>> import pygame>>>

木有報錯,這就說明咱安裝成功了。接下來就開始愉快的pygame之旅吧。

總結

整體的安裝過程是很讓人糾結的。尤其是對那些剛入門的童鞋。但是,這也是最有價值的經驗了。因為這些庫的安裝會讓你對Python的架構更加的熟悉。整體結構的把握也會更加的好。

所以,靜下心來。一步一步的,進行操作就是了。相信這會對你Python有很大的協助的。也希望大家多多支援幫客之家。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.