suse 11 pip pip3使用過程中遇到的各種問題


在安裝完成python3.6后,使用pip3安裝某些插件,報如下錯誤

linux-9qk9:~ # pip3 install ipython
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Collecting ipython
Could not fetch URL https://pypi.python.org/simple/ipython/: There was a problem confirming the ssl certificate: Can't connect to HTTPS URL because the SSL module is not available. - skipping
Could not find a version that satisfies the requirement ipython (from versions: )
No matching distribution found for ipython

 

我們進入Python3,結果查看到沒有安裝ssl,由於我們使用的是suse11系統,不想centos有Yum源可以使用命令yum install openssl-devel -y 進行ssl-devel安裝,那怎么辦呢,baidu了一下需要安裝libopenssl,我們就把原來安裝的Python3刪除重新安裝下

linux-9qk9:~ # python3
Python 3.6.4 (default, Jul 11 2018, 01:24:13) 
[GCC 4.3.4 [gcc-4_3-branch revision 152973]] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/python3/lib/python3.6/ssl.py", line 101, in <module>
    import _ssl             # if we can't import it, let the error propagate
ModuleNotFoundError: No module named '_ssl'
>>> exit()
linux-9qk9:~ # rm -rf /usr/local/python3 //刪除原來安裝的python3




安裝libopenssl-devel, 這個有點類似centos里面的openssl-devel包,注意版本

linux-9qk9:/tmp/software_download # rpm -qi openssl
Name : openssl Relocations: (not relocatable)
Version : 0.9.8j Vendor: SUSE LINUX Products GmbH, Nuernberg, Germany
Release : 0.50.1 Build Date: Mon Mar 25 11:10:09 2013
Install Date: Tue Jul 10 09:41:57 2018 Build Host: acklins
Group : Productivity/Networking/Security Source RPM: openssl-0.9.8j-0.50.1.src.rpm
Size : 1182276 License: BSD 3-Clause
Signature : RSA/8, Mon Mar 25 11:10:24 2013, Key ID e3a5c360307e3d54
Packager : http://bugs.opensuse.org
URL : http://www.openssl.org/
Summary : Secure Sockets and Transport Layer Security
Description :
The OpenSSL Project is a collaborative effort to develop a robust,
commercial-grade, full-featured, and open source toolkit implementing
the Secure Sockets Layer (SSL v2/v3) and Transport Layer Security (TLS
v1) protocols with full-strength cryptography. The project is managed
by a worldwide community of volunteers that use the Internet to
communicate, plan, and develop the OpenSSL toolkit and its related
documentation.

Derivation and License

OpenSSL is based on the excellent SSLeay library developed by Eric A.
Young and Tim J. Hudson. The OpenSSL toolkit is licensed under an
Apache-style license, which basically means that you are free to get it
and to use it for commercial and noncommercial purposes.

Please read the file /usr/share/doc/packages/openssl/README-FIPS.txt
for information on FIPS-140-2 compliant mode of operation of the
openssl shared libraries.

 

Authors:
--------
Mark J. Cox <mark@openssl.org>
Ralf S. Engelschall <rse@openssl.org>
Dr. Stephen Henson <steve@openssl.org>
Ben Laurie <ben@openssl.org>
Bodo Moeller <bodo@openssl.org>
Ulf Moeller <ulf@openssl.org>
Holger Reif <holger@openssl.org>
Paul C. Sutton <paul@openssl.org>
Distribution: SUSE Linux Enterprise 11

 

linux-9qk9:/tmp/software_download # rpm -ivh libopenssl-devel-0.9.8j-2.1.x86_64.rpm 
warning: libopenssl-devel-0.9.8j-2.1.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 7af5fd64
Preparing... ########################################### [100%]
1:libopenssl-devel ########################################### [100%]
linux-9qk9:/tmp/software_download #







linux-9qk9:~ # cd /tmp/software_download/Python-3.6.4/     //進入Python3安裝目錄
linux-9qk9:/tmp/software_download/Python-3.6.4 # ./configure --prefix=/usr/local/python3 

linux-9qk9:/tmp/software_download/Python-3.6.4 # make

linux-9qk9:/tmp/software_download/Python-3.6.4 # make install

 

這次import ssl沒有報錯

linux-9qk9:/tmp/software_download # python3
Python 3.6.4 (default, Jul 11 2018, 04:13:04)
[GCC 4.3.4 [gcc-4_3-branch revision 152973]] on linux
Type "help", "copyright", "credits" or "license" for more information.
Traceback (most recent call last):
File "/etc/pythonstart", line 7, in <module>
import readline
ModuleNotFoundError: No module named 'readline'
>>> import ssl
>>>



ps,如果安裝了libopenssl-devel還是不行的話,我們就要去找一台已經import ssl不報錯的機器比如下面那台機器,
將_ssl.cpython-36m-x86_64-linux-gnu.so復制到/usr/local/python3/lib/python3.6/lib-dynload目錄下面就可以了

inspect01:/usr/local/python3/lib/python3.6/lib-dynload # ls *ssl*
_ssl.cpython-36m-x86_64-linux-gnu.so 
inspect01:/usr/local/python3/lib/python3.6/lib-dynload #




 

安裝好以后我們在用Pip3測試下能否安裝軟件,可以看到這個報錯像是網絡不通的樣子

linux-9qk9:/tmp/software_download # pip3 install ipython
Collecting ipython
  Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7fb7ceaf68d0>: Failed to establish a new connection: [Errno 101] Network is unreachable',)': /simple/ipython/
  Retrying (Retry(total=3, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7fb7ceaf6cf8>: Failed to establish a new connection: [Errno 101] Network is unreachable',)': /simple/ipython/
  Retrying (Retry(total=2, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7fb7ceaf6898>: Failed to establish a new connection: [Errno 101] Network is unreachable',)': /simple/ipython/
  Retrying (Retry(total=1, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7fb7ceaf62e8>: Failed to establish a new connection: [Errno 101] Network is unreachable',)': /simple/ipython/
  Retrying (Retry(total=0, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7fb7ceaf69b0>: Failed to establish a new connection: [Errno 101] Network is unreachable',)': /simple/ipython/
  Could not find a version that satisfies the requirement ipython (from versions: )
No matching distribution found for ipython

 

那我們來ping 一下baidu看看能不能ping通,我們看到是可以ping通的,

linux-9qk9:/tmp/software_download # ping www.baidu.com
PING www.a.shifen.com (61.135.169.121) 56(84) bytes of data.
64 bytes from 61.135.169.121: icmp_seq=1 ttl=50 time=25.0 ms
64 bytes from 61.135.169.121: icmp_seq=2 ttl=50 time=27.5 ms
^C
--- www.a.shifen.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 25.073/26.292/27.511/1.219 ms
linux-9qk9:/tmp/software_download # 

 

那么這個是怎么一回事呢,網上搜索了很久有的說是要修改鏡像源頭,比如下面這個鏈接寫的那樣

https://www.cnblogs.com/biglittleant/p/6944180.html

我們按照他的方式改下看看

linux-9qk9:/tmp/software_download # mkdir ~/.pip 
linux-9qk9:/tmp/software_download # vim ~/.pip/pip.conf [global] index-url = http://mirrors.aliyun.com/pypi/simple/ [install] trusted-host = mirrors.aliyun.com


:wq!

 

重新測試下Pip3發現還是不行,

linux-9qk9:/tmp/software_download # pip3 install ipython
Collecting ipython
  Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.HTTPConnection object at 0x7f7550191438>: Failed to establish a new connection: [Errno 111] Connection refused',)': /pypi/simple/ipython/
  Retrying (Retry(total=3, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.HTTPConnection object at 0x7f7550191be0>: Failed to establish a new connection: [Errno 111] Connection refused',)': /pypi/simple/ipython/
  Retrying (Retry(total=2, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.HTTPConnection object at 0x7f7550191c88>: Failed to establish a new connection: [Errno 111] Connection refused',)': /pypi/simple/ipython/
  Retrying (Retry(total=1, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.HTTPConnection object at 0x7f7550191ef0>: Failed to establish a new connection: [Errno 111] Connection refused',)': /pypi/simple/ipython/
  Retrying (Retry(total=0, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.HTTPConnection object at 0x7f7550191c18>: Failed to establish a new connection: [Errno 111] Connection refused',)': /pypi/simple/ipython/
  Could not find a version that satisfies the requirement ipython (from versions: )
No matching distribution found for ipython

 

這下比較麻煩了,搜索了半天百度也沒發現什么好的解決辦法,網也通的,鏡像也設置了,還能怎么搞呢,后來想來想去估計還是網絡問題,我們先把他的國內鏡像刪除

 

linux-9qk9:/tmp/software_download # rm -rf ~/.pip

查看網絡,我這里虛擬機用的是一個網卡,橋接模式

linux-9qk9:/tmp/software_download # 
linux-9qk9:/tmp/software_download # ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0C:29:67:54:7E  
          inet addr:172.16.19.71  Bcast:172.16.19.127  Mask:255.255.255.128
          inet6 addr: fe80::20c:29ff:fe67:547e/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:117437 errors:0 dropped:3 overruns:0 frame:0
          TX packets:37807 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:50453989 (48.1 Mb)  TX bytes:6766192 (6.4 Mb)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:39336 errors:0 dropped:0 overruns:0 frame:0
          TX packets:39336 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:229684037 (219.0 Mb)  TX bytes:229684037 (219.0 Mb)

linux-9qk9:/tmp/software_download # 

 

 我們再來添加一個網卡,NAT模式

linux-9qk9:/etc/sysconfig/network # ls
config  dhcp  if-down.d  if-up.d  ifcfg-eth0  ifcfg-lo  ifcfg.template  ifroute-lo  providers  routes  scripts
linux-9qk9:/etc/sysconfig/network # 

linux-9qk9:/etc/sysconfig/network # view ifcfg-eth1
BOOTPROTO='static' #靜態IP
BROADCAST='192.168.27.255' #廣播地址
IPADDR='192.168.27.4' #IP地址
NETMASK='255.255.255.0' #子網掩碼
NETWORK='192.168.27.0' #網絡地址
STARTMODE='auto' #開機啟動網絡

wq!

 

 

linux-9qk9:/etc/sysconfig/network # view routes
default 192.168.27.2                    #這個是對應的網關,和你虛擬機里面設置的一樣

 

wq!

 

 

 

 linux-9qk9:/etc/sysconfig/network # view /etc/resolv.conf 

nameserver=8.8.8.8
nameserver=8.8.4.4
 
 
wq!
 
 
添加網卡
 

 

 

 

 
 
 
 
 

重啟網絡
linux-9qk9:~ # service network restart    

 

查看新ip地址

linux-9qk9:~ # ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:67:54:7E
inet addr:172.16.19.71 Bcast:172.16.19.127 Mask:255.255.255.128
inet6 addr: fe80::20c:29ff:fe67:547e/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:966 errors:0 dropped:0 overruns:0 frame:0
TX packets:303 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:196254 (191.6 Kb) TX bytes:40638 (39.6 Kb)

eth1 Link encap:Ethernet HWaddr 00:0C:29:67:54:88
inet addr:192.168.27.4 Bcast:192.168.27.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe67:5488/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:11 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:866 (866.0 b)

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:46 errors:0 dropped:0 overruns:0 frame:0
TX packets:46 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:3140 (3.0 Kb) TX bytes:3140 (3.0 Kb)

 

 

 

重新用pip3安裝,發現報錯不一樣了,這是一個好現象,


linux-9qk9:~ # pip3 install ipython
Collecting ipython
Could not fetch URL https://pypi.python.org/simple/ipython/: There was a problem confirming the ssl certificate: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:777) - skipping
Could not find a version that satisfies the requirement ipython (from versions: )
No matching distribution found for ipython

 

我們在把前面的國內鏡像源添加下

linux-9qk9:~ # mkdir ~/.pip 
linux-9qk9:~ # view ~/.pip/pip.conf
[global]
index-url = http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host = mirrors.aliyun.com

 

我們可以看到這次pip3 install成功了

linux-9qk9:~ # pip3 install ipython
Collecting ipython
  Downloading http://mirrors.aliyun.com/pypi/packages/b1/7f/91d50f28af3e3a24342561983a7857e399ce24093876e6970b986a0b6677/ipython-6.4.0-py3-none-any.whl (750kB)
    100% |████████████████████████████████| 757kB 393kB/s 
Collecting traitlets>=4.2 (from ipython)
  Downloading http://mirrors.aliyun.com/pypi/packages/93/d6/abcb22de61d78e2fc3959c964628a5771e47e7cc60d53e9342e21ed6cc9a/traitlets-4.3.2-py2.py3-none-any.whl (74kB)
    100% |████████████████████████████████| 81kB 421kB/s 
Collecting decorator (from ipython)
  Downloading http://mirrors.aliyun.com/pypi/packages/bc/bb/a24838832ba35baf52f32ab1a49b906b5f82fb7c76b2f6a7e35e140bac30/decorator-4.3.0-py2.py3-none-any.whl
Collecting pickleshare (from ipython)
  Downloading http://mirrors.aliyun.com/pypi/packages/9f/17/daa142fc9be6b76f26f24eeeb9a138940671490b91cb5587393f297c8317/pickleshare-0.7.4-py2.py3-none-any.whl
Collecting pygments (from ipython)
  Downloading http://mirrors.aliyun.com/pypi/packages/02/ee/b6e02dc6529e82b75bb06823ff7d005b141037cb1416b10c6f00fc419dca/Pygments-2.2.0-py2.py3-none-any.whl (841kB)
    100% |████████████████████████████████| 849kB 394kB/s 
Collecting prompt-toolkit<2.0.0,>=1.0.15 (from ipython)
  Downloading http://mirrors.aliyun.com/pypi/packages/04/d1/c6616dd03701e7e2073f06d5c3b41b012256e42b72561f16a7bd86dd7b43/prompt_toolkit-1.0.15-py3-none-any.whl (247kB)
    100% |████████████████████████████████| 256kB 380kB/s 
Collecting simplegeneric>0.8 (from ipython)
  Downloading http://mirrors.aliyun.com/pypi/packages/3d/57/4d9c9e3ae9a255cd4e1106bb57e24056d3d0709fc01b2e3e345898e49d5b/simplegeneric-0.8.1.zip
Collecting backcall (from ipython)
  Downloading http://mirrors.aliyun.com/pypi/packages/1b/b3/0708228132a772de8802967af71d00c6b1f2f407e6f8efcc7055ac5900fe/backcall-0.1.0.zip
Collecting pexpect; sys_platform != "win32" (from ipython)
  Downloading http://mirrors.aliyun.com/pypi/packages/89/e6/b5a1de8b0cc4e07ca1b305a4fcc3f9806025c1b651ea302646341222f88b/pexpect-4.6.0-py2.py3-none-any.whl (57kB)
    100% |████████████████████████████████| 61kB 418kB/s 
Collecting jedi>=0.10 (from ipython)
  Downloading http://mirrors.aliyun.com/pypi/packages/3d/68/8bbf0ef969095a13ba0d4c77c1945bd86e9811960d052510551d29a2f23b/jedi-0.12.1-py2.py3-none-any.whl (174kB)
    100% |████████████████████████████████| 184kB 409kB/s 
Requirement already satisfied: setuptools>=18.5 in /usr/local/python3/lib/python3.6/site-packages (from ipython)
Collecting ipython-genutils (from traitlets>=4.2->ipython)
  Downloading http://mirrors.aliyun.com/pypi/packages/fa/bc/9bd3b5c2b4774d5f33b2d544f1460be9df7df2fe42f352135381c347c69a/ipython_genutils-0.2.0-py2.py3-none-any.whl
Collecting six (from traitlets>=4.2->ipython)
  Downloading http://mirrors.aliyun.com/pypi/packages/67/4b/141a581104b1f6397bfa78ac9d43d8ad29a7ca43ea90a2d863fe3056e86a/six-1.11.0-py2.py3-none-any.whl
Collecting wcwidth (from prompt-toolkit<2.0.0,>=1.0.15->ipython)
  Downloading http://mirrors.aliyun.com/pypi/packages/7e/9f/526a6947247599b084ee5232e4f9190a38f398d7300d866af3ab571a5bfe/wcwidth-0.1.7-py2.py3-none-any.whl
Collecting ptyprocess>=0.5 (from pexpect; sys_platform != "win32"->ipython)
  Downloading http://mirrors.aliyun.com/pypi/packages/d1/29/605c2cc68a9992d18dada28206eeada56ea4bd07a239669da41674648b6f/ptyprocess-0.6.0-py2.py3-none-any.whl
Collecting parso>=0.3.0 (from jedi>=0.10->ipython)
  Downloading http://mirrors.aliyun.com/pypi/packages/31/19/ae6ded1b16b596e594dffe1916b365c658ddf93396824ed069a60da22b79/parso-0.3.0-py2.py3-none-any.whl (88kB)
    100% |████████████████████████████████| 92kB 389kB/s 
Installing collected packages: ipython-genutils, decorator, six, traitlets, pickleshare, pygments, wcwidth, prompt-toolkit, simplegeneric, backcall, ptyprocess, pexpect, parso, jedi, ipython
  Running setup.py install for simplegeneric ... done
  Running setup.py install for backcall ... done
Successfully installed backcall-0.1.0 decorator-4.3.0 ipython-6.4.0 ipython-genutils-0.2.0 jedi-0.12.1 parso-0.3.0 pexpect-4.6.0 pickleshare-0.7.4 prompt-toolkit-1.0.15 ptyprocess-0.6.0 pygments-2.2.0 simplegeneric-0.8.1 six-1.11.0 traitlets-4.3.2 wcwidth-0.1.7
linux-9qk9:~ # 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM