Gasp (Graphics API for Students of Python) will enable us to write PRograms involving graphics.
安裝Windows版GASP 在《How to Think Like a Computer Scientist Learning with Python 》4.11GASP章節中,需要安裝GASP。通過文章給的網址http://dev.laptop.org/pub/gasp/downloads進入下載頁面。由于我是Windows 7系統,所以選擇
3.Microsoft Windows
The latest version of GASP does not run on Windows, due to unfortunate implementation details. In the meantime, you can use older versions of GASP from the 0.2.x series. Install PyGame, then download and install the 0.2.0beta1 GASP package. Assistance with porting the 0.3.x series is appreciated, email the mailing list if you can help.
1.首先安裝PyGame,通過頁面鏈接,進入http://www.pygame.org/wiki/GettingStarted
通過描述得知,在dos里面輸入pip install pygame 即可
但是我在這個過程中,第一次失敗了,仔細看錯誤描述,要求先更新pip的版本。更新pip后,成功安裝pygame
2.下載python-gasp-0.2.0beta1.win32.exe,雙擊安裝。 由于我是windows 64系統,gasp是32位的,一開始提示no python installation found in the registry。 解決辦法: win+r,輸入regedit,在注冊表新建HKEY_LOCAL_MACHINE/SOFTWARE/Wow6432Node/Python/PythonCore/2.7/InstallPath 項,并把HKEY_LOCAL_MACHINE/SOFTWARE/Python/PythonCore/2.7/InstallPath的數據復制到上面新建的項里面
現在可以在Python27/Lib/site-packages路徑下看見多了gasp,gasp-0.2.0beta1-py2.6.egg-info,pygame,pygame-1.9.3.dist-info 4個文件夾
執行 復制教材的腳本,命名為“gasp.py”
from gasp import *begin_graphics()Circle((200, 200), 60)Line((100, 400), (580, 200))Box((400, 350), 120, 100)update_when('key_pressed')end_graphics()運行發現一直報錯,
c:/>python gasp.pyTraceback (most recent call last): File "gasp.py", line 1, in <module> from gasp import * File "c:/gasp.py", line 3, in <module> begin_graphics()NameError: name 'begin_graphics' is not defined這個問題把頭都搞大了。最后在同事的幫助下,發現跟pygame有關系。他沒有安裝pygame,報的錯跟我一樣。但是我是已經安裝了pygame,也許是版本兼容問題吧。最后只能把gasp.py腳本放到C:/Python27/Lib/site-packages 文件夾才能成功運行。 如果有朋友知道是什么原因,請留言,感謝~!
新聞熱點
疑難解答