加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

Python中的easy_install工具在linux安装与使用解析

发布时间:2020-12-17 07:17:45 所属栏目:Python 来源:网络整理
导读:对Python中的easy_install感兴趣的小伙伴,下面一起跟随编程之家 jb51.cc的小编两巴掌来看看吧! Python中的easy_install工具用起来非常好用,它的作用类似于Php中的pear,或者Ruby中的gem,或者Perl中的cpan。 1.easy_install安装 如果想使用easy_install工
对Python中的easy_install感兴趣的小伙伴,下面一起跟随编程之家 52php.cn的小编两巴掌来看看吧!

Python中的easy_install工具用起来非常好用,它的作用类似于Php中的pear,或者Ruby中的gem,或者Perl中的cpan。

1.easy_install安装

如果想使用easy_install工具,需要先安装setuptools,不过更酷的方法是使用ez_setup.py脚本:
执行如下命令:


shell#  wget -q http://peak.telecommunity.com/dist/ez_setup.py
shell#  python ez_setup.py

# End www.52php.cn

安装完后,最好确保easy_install所在目录已经被加到PATH环境变量里:

Linux: /usr/local/bin

比如说要安装Python的MySQL支持,可以执行如下命令,系统会自动在pypi网站列表里查找相关软件包:


easy_install MySQL-python

# End www.52php.cn

通过easy_install安装软件,相关安装信息会保存到easy-install.pth文件里,路径类似如下形式:

Linux:/usr/local/lib/python25/site-packages/easy-install.pth

如果想删除通过easy_install安装的软件包,比如说:MySQL-python,可以执行命令:


# @param linux下easy_install的安装与使用详解
# @author 编程之家 52php.cn|52php.cn 
easy_install -m MySQL-python

# End www.52php.cn

此操作会从easy-install.pth文件里把MySQL-python的相关信息抹去,剩下的egg文件,你可以手动删除。

2.easy_install使用详解

方法一:
根据你想要的安装包名来进行easy_install,工具会检索网页查询最新版本的包,自动下载、构建和安装


easy_install MySQL-python

# End www.52php.cn

方法二:
指定网址来更新或安装,类似使用一,多了个参数-f和用来指定页面的地址只指定页面地址


easy_install -f http://pythonpaste.org/package_index.html SQLObject

# End www.52php.cn

方法三:
只使用网址来easy_install安装


easy_install http://example.com/path/to/MyPackage-1.2.3.tgz

# End www.52php.cn

方法四
easy_install安装下载好的egg文件(egg文件是用setup tools打包的压缩文件)


easy_install /my_downloads/OtherPackage-3.2.1-py2.3.egg

# End www.52php.cn

方法五:
升级包,有时候你需要更新包的版本


easy_install --upgrade PyProtocols

# End www.52php.cn

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读