由於功能及程序依賴,需要將Centos上的python從2.6升級成2.7,把碰到的一些問題記錄如下:
安裝好2.7后將原來的/usr/bin/python改成/usr/bin/python26,並將2.7的bin目錄加入執行路徑
Question1: 執行yum報No module named yum
[root@zejin240 ~]# yum list There was a problem importing one of the Python modules required to run yum. The error leading to this problem was: No module named yum Please install a package which provides this module, or verify that the module is installed correctly. It's possible that the above module doesn't match the current version of Python, which is: 2.7.12 (default, Jul 6 2016, 18:40:00) [GCC 4.4.7 20120313 (Red Hat 4.4.7-17)] If you cannot solve this problem yourself, please go to the yum faq at: http://yum.baseurl.org/wiki/Faq
解決方法:
vi /usr/binyum
#!/usr/bin/python26
Question2: 執行pip時提示 ImportError: No module named pip
解決方法:python -m ensurepip
Questions3:源碼安裝paramiko出現各種模塊找不到
解決方法:
pip install -I pycrypto
pip install -I paramiko