pip: command not found 一系列報錯

#安裝python2.7版本

tar xvf Python-2.7.9.tar.xz
cd Python-2.7.9
./configure --prefix=/usr/bin/python2.7
make
make install

mv /usr/bin/python /usr/bin/python.bak
ln -s /usr/bin/python2.7/bin/python2.7 /usr/bin/python

問題1:yum安裝報錯

No module named yum

解決:
前面安裝了python2.7,默認2.6。python 版本更改後,
/usr/bin/yum 文件需要更新 首行改爲 #!/usr/bin/python2.6

問題2:pip command not found

[root@ Python-2.7.9]# pip install jinja2
-bash: pip: command not found

解決

[root@ ~]#  yum -y install python-setuptools
[root@ ~]#  easy_install pip

問題3:ImportError: No module named pkg_resources

[root@ ~]# easy_install pip
Traceback (most recent call last):
  File "/usr/bin/easy_install", line 5, in <module>
    from pkg_resources import load_entry_point
ImportError: No module named pkg_resources

解決:
[root@ ~]# curl https://bootstrap.pypa.io/ez_setup.py | python

問題4:easy_install pip 報錯 The ‘distribute==0.6.10‘ distribution was not found

[root@ ~]# easy_install pip
Traceback (most recent call last):
  File "/usr/bin/easy_install", line 5, in <module>
    from pkg_resources import load_entry_point
  File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 3019, in <module>
  File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 3003, in _call_aside
  File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 3032, in _initialize_master_working_set
  File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 655, in _build_master
  File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 963, in require
  File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 849, in resolve
pkg_resources.DistributionNotFound: The ‘distribute==0.6.10‘ distribution was not found and is required by the application

解決:安裝distribute

wget http://pypi.python.org/packages/source/d/distribute/distribute-0.6.10.tar.gz --no-check-certificate
tar zxvf distribute-0.6.10.tar.gz
cd distribute-0.6.10
python setup.py install

[root@ ~]# easy_install pip 成功
wKiom1mhiBnQpyAOAAEBSCmCOfA625.png

問題5:上圖顯示安裝pip成功,但執行命令依然顯示 command not found

[root@ ~]# pip install jinja2
-bash: pip: command not found
排查:
[root@ ~]# which pip
[root@~]# ls /usr/bin/pip
ls: 無法訪問/usr/bin/pip: 沒有那個文件或目錄

解決:創建軟連接:

[root@localhost ~]# ln -s /usr/bin/python2.7/bin/pip /usr/bin/pip

安裝成功

[root@~]# pip install jinja2
Collecting jinja2
  Downloading Jinja2-2.9.6-py2.py3-none-any.whl (340kB)
    100% |████████████████████████████████| 348kB 28kB/s 
Collecting MarkupSafe>=0.23 (from jinja2)
  Downloading MarkupSafe-1.0.tar.gz
Installing collected packages: MarkupSafe, jinja2
  Running setup.py install for MarkupSafe ... done
Successfully installed MarkupSafe-1.0 jinja2-2.9.6

問題6:pip認證失敗,報錯“There was a problem confirming the ssl certificate: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed”

[root@localhost Python-2.7.13]# pip install xlsxwriter
Collecting xlsxwriter
  Could not fetch URL https://pypi.python.org/simple/xlsxwriter/: There was a problem confirming the ssl certificate: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:661) - skipping
  Could not find a version that satisfies the requirement xlsxwriter (from versions: )
No matching distribution found for xlsxwriter
You are using pip version 9.0.1, however version 9.0.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

解決:寫一個pip配置文件~/.pip/pip.conf,在配置文件中加入trusted-host=pypi.python.org

[global]
timeout = 6000
#index-url = http://e.pypi.python.org/simple
index-url = https://pypi.python.org/simple/
[install]
use-mirrors = true
#mirrors = http://e.pypi.python.org
mirrors = https://pypi.python.org
trusted-host=pypi.python.org
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章