GASP的安装和执行

来源:互联网 发布:ip网络功放怎么设置 编辑:程序博客网 时间:2024/06/15 12:47

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 文件夹才能成功运行。
如果有朋友知道是什么原因,请留言,感谢~!

0 0
原创粉丝点击