python模块管理工具,Python的包管理工具

Python的包管理工具

python包管理工具

python包管理工具简介

3850bbedb44efea46d1f79e45b20d747.png

distribute是setuptools的取代,pip是easy_install的取代。

Distribute是对标准库disutils模块的增强,我们知道disutils主要是用来更加容易的打包和分发包,特别是对其他的包有依赖的包。

Distribute被创建是因为Setuptools包不再维护了。

Pip 是安装python包的工具,提供了安装包,列出已经安装的包,升级包以及卸载包的功能。

Pip 是对easy_install的取代,提供了和easy_install相同的查找包的功能,因此可以使用easy_install安装的包也同样可以使用pip进行安装。

关于这些包工具可以参考 http://guide.python-distribute.org/installation.html#installing-pip

python包管理工具的安装

安装Distribute

可以通过distribute_setup.py 脚本来安装Distribute,也可以通过easy_install, pip,源文件来安装,不过使用distribute_setup.py来安装是最简单和受欢迎的方式

$ curl -0 http://python-distribute.org/distribute_setup.py

$ sudo python distribute_setup.py

安装Pip(python3中自带pip,不用安装)

Pip的安装可以通过源代码包,easy_install或者脚本。

下面介绍一下各种安装方法:

1)源代码方式:    #need install setuptools

$ wget http://pypi.python.org/packages/source/p/pip/pip-0.7.2.tar.gz (替换为最新的包)

$ tar xzf pip-0.7.2.tar.gz

$ cd pip-0.7.2

$ python setup.py install

2)easy_install:    #need installeasy_install

$ easy_install pip

3)get_pip.py 脚本:    #need install curl

$ curl -0 https://raw.github.com/pypa/pip/master/contrib/get-pip.py

$ sudo python get-pip.py

4)sudo apt-get install python-pip

pip版本更新

如果收到提示可以进行pip更新:

f419a90998195346b581cee8d04a6ba3.png

或者

def411114335fbcd0b09522c26c6c532.png

Pip的使用

安装package

$ pip install Markdown

列出安装的packages

$ pip freeze

安装特定版本的package

通过使用==, >=, <=, >,

$ pip install 'Markdown<2.0'

$ pip install 'Markdown>2.0,<2.0.3'

升级包

升级包到当前最新的版本,可以使用-U 或者 --upgrade

$ pip install -U Markdown

卸载包

$ pip uninstall Markdown

查询包

pip search "Markdown"

Note:包安装后的py文件路径:/usr/local/lib/python2.7/dist-packages

windows下安装pip:

1 Python 3.4and later include pip by default

加入path中

2 对于Python 2 ≤ 2.7.8 and Python 3 ≤ 3.3

2.1Official instructions:

The official documentation tells users to install Pip and each its dependencies from source.

Per http://www.pip-installer.org/en/latest/installing.html

Download get-pip.py, being careful to save it as a .py file rather than .txt. Then, run it from the command prompt.

python get-pip.py

You possibly need an administrator command prompt to do this. Follow http://technet.microsoft.com/en-us/library/cc947813(v=ws.10).aspx

[https://pip.pypa.io/en/latest/installing.html]

2.2下载安装

setuptools-7.0.win-amd64-py2.7.exe

pip-1.5.6.win-amd64-py2.7.exe

For me, this installed Pip at D:\Python27\Scripts\pip.exe.

安装完成后在目录D:\python2.7.8\Scripts就有pip,把路径加到环境变量里。

手动添加电脑--右键属性--高级设置--环境变量--path 添加“;D:\python2.7.8\Scripts”

或者运行PythonXX\Tools\Scripts\win_add2path.py

然后 easy_install pip    就安装上了pip.

Now you should be able to run pip from the command line. Try installing a package.

pip install gensim

3通过easy_install安装

setuptools-0.7.4.tar.gz

cmd窗口进入到解压文件目录进行安装

python ez_setup.py install

之后在环境变量的path条目添加%python_address%和%python_address%/Scripts

然后使用easy_install安装pip安装工具:easy_install pip

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值