python学习之接口设计

中间时间在看小甲鱼的python视频,对python有了一个直观的感受。现在继续think python的学习。争取在两个月内将这本书啃下来。

在安装swampy的过程中,费了很大劲,模块一直安装不成功。

下载地址://www.greenteapress.com/thinkpython/swampy/install.html

官网对python3安装该模块的介绍是:The simplest way to use this code is to unzip it in your home directory, cd into the unzipped directory and work there. Or you can put it any place you like, then add the new directory to the Python search path.即将swampy-2.1.5.python3.zip解压至根目录,然后cd到解压缩目录并在那里工作。或者放在任意想放的地方,然后把新目录加至python的搜索路径上。

最后实现的方法是:

1.解压swampy-2.1.5.python3.zip至根目录

2.将swampy模块安装到python搜索路径,即增添.pth文件。在site-packages添加一个路径文件,如mypkpath.pth,必须以.pth为后缀,写上swampy文件所在的目录名称。

测试

import sys 
sys.path

3.下载setuptools:https://pypi.python.org/pypi/setuptools/1.1.4

解压缩,打开ez_setup.py

4.cmd,cd到python目录下的Scripts文件夹,运行:easy_install.exe swampy

测试

import swampy.TurtleWorld

第一遍成功以后,由于python自身问题,卸载重装软件以后,再次使用上述方法,失败。重启机器,再次失败。错误原因如下所示:

 

再次重装python至E盘后,提示swampy已经安装成功,

 

但是在idle中输入import swampy 再次显示没有该模块。在另一交互式编辑器上显示该模块存在,但在其中的TurtleWorld却没有。

 

posted on 2017-11-20 08:55  土间埋  阅读(867)  评论(0编辑  收藏  举报

导航