一、首先咱們剛剛說的pip是什麼?html
在pip的python官網上咱們能夠看到,pip 是「A tool for installing and managing Python packages.」,也就是說pip是python的軟件安裝工具,下面是pip的使用方法:python
安裝包: linux
pip install SomePackage
查看安裝包時安裝了哪些文件:git
pip show --files SomePackage
查看哪些包有更新:github
pip show --files SomePackage
更新一個軟件:vim
pip install --upgrade SomePackage
卸載軟件:windows
pip uninstall SomePackage
因此,有了pip咱們就能夠自動的安裝其餘軟件包,好比咱們須要的 nose、virtualenv、distribute 、paramiko等bash
2. 安裝 pip軟件包python2.7
pip官網地址:https://pypi.python.org/pypi/pipide
開始安裝:
t
#tar -xvf pip-1.4.1.tar.gz #cd pip-1.4.1/ #python setup.py install Traceback (most recent call last): File "setup.py", line 5, in <module> from setuptools import setup, find_packages ImportError: No module named setuptools
安裝pip時提示setup.py中使用setuptools中的模塊,可是電腦中並無安裝setuptools軟件包,因此咱們須要先下載並安裝 setuptools!
3. 安裝setuptools軟件包
(1)下載setuptools包 # wget http://pypi.python.org/packages/source/s/setuptools/setuptools-2.0.tar.gz (2)解壓setuptools包 # tar zxvf setuptools-2.0.tar.gz # cd setuptools-2.0 (3)編譯setuptools # python setup.py build (4)開始執行setuptools安裝 # python setup.py install
4、 再次安裝pip,並使用pip安裝其餘軟件包
如今,setuptools已經安裝好,咱們再次進入pip-1.4.1目錄,使用 「python setup.py install」 命令安裝pip:
# cd pip-1.4.1/ # python setup.py install
安裝好pip以後,咱們就能夠直接使用pip安裝其餘軟件包了:
最終安裝咱們的paramiko pip install paramiko
paramiko的官網:https://github.com/paramiko/paramiko
若是安裝paramiko出現如下錯誤,請按照介紹安裝
command 'gcc' failed with exit status 1 view plain <strong>[/pycrypto-2.0.1]$ sudo python setup.py build running build running build_py running build_ext building 'Crypto.Hash.MD2' extension gcc -pthread -fno-strict-aliasing -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector ——param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fPIC -Isrc/ -I/usr/include/python2.4 -c src/MD2.c -o build/temp.linux-x86_64-2.4/src/MD2.o unable to execute gcc: No such file or directory error: command 'gcc' failed with exit status 1</strong>
解決方案1:
多是缺乏python-dev安裝包致使
解決辦法: CentOS yum -y install python-dev* yum -y install gcc 最後再次執行 : pip install paramiko
2,導入出現錯誤
python>> import paramiko (Crypto error: 'module' object has no attribute 'HAVE_DECL_MPZ_POWM_SEC' 注:若是Python是2.7的話: 找到 /usr/lib/python2.7/site-packages/Crypto/Util/number.py 把if _fastmath is not None and not _fastmath.HAVE_DECL_MPZ_POWM_SEC: 註釋了 #if _fastmath is not None and not _fastmath.HAVE_DECL_MPZ_POWM_SEC: ) 注:若是Python是2.6的話: 修改 vim /usr/lib64/python2.6/site-packages/Crypto/Util/number.py 註釋了 #if _fastmath is not None and not _fastmath.HAVE_DECL_MPZ_POWM_SEC: ) Python 2.6.6 (r266:84292, Jul 23 2015, 15:22:56) [GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import paramiko >>> Python 2.7.3 (default, Jan 5 2013, 10:09:00) [GCC 4.4.6 20120305 (Red Hat 4.4.6-4)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import paramiko >>>
##########################################################################################
5、windows7 安裝paramiko
1,安裝Python ,下載直接下一步便可 2,安裝ActivePython-2.7.10.12-win64-x64.msi
3,安裝pywin32-220.win-amd64-py2.7.exe https://sourceforge.net/projects/pywin32/files/pywin32/Build%20220/ 4,Windows命令終端執行 pypm install paramiko
5,測試