zoukankan      html  css  js  c++  java
  • 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:~ # 
  • 相关阅读:
    BZOJ 3531[Sdoi2014]旅行
    BZOJ4998 星球联盟
    BZOJ2959 长跑
    【北京集训D2T3】tvt
    [Bzoj]5343: [Ctsc2018]混合果汁
    HGOI20190810 省常中互测3
    HGOI20190809 省常中互测2
    HGOI20190808 省常中互测1
    组合排列和组合数 学习笔记
    2-SAT (two-statisfiability) 算法 学习笔记
  • 原文地址:https://www.cnblogs.com/qinhan/p/9299240.html
Copyright © 2011-2022 走看看