python模块管理工具,Python的包管理工具
Python的包管理工具
python包管理工具
python包管理工具簡介
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更新:
或者
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
總結
以上是生活随笔為你收集整理的python模块管理工具,Python的包管理工具的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 英伟达演示 RTX 4080 笔记本 G
- 下一篇: oracle 11g函数包缓存,Orac