Kubuntu 18.10 上的 pip3、pipenv 和 add-apt-repository 损坏,可能是 SSL 库出了问题

Kubuntu 18.10 上的 pip3、pipenv 和 add-apt-repository 损坏,可能是 SSL 库出了问题

我在 Kubuntu 18.10 上安装了 python 2.7.15 和 3.6.7,输出lsb_release -a

LSB Version:    core-9.20170808ubuntu1-noarch:security-9.20170808ubuntu1-noarch
Distributor ID: Ubuntu
Description:    Ubuntu 18.10
Release:        18.10
Codename:       cosmic

pip适用于我的机器,因为它适用于 python 2.7,并且输出pip -V

pip 9.0.1 from /usr/lib/python2.7/dist-packages (python 2.7)

但输入 pip3 会出现段错误。输出只是Segmentation fault。pipenv 的输出相同。我尝试多次删除和安装 python3-pip,删除了 中的 pip 缓存/home/<username>/.cache。当我尝试使用 apt-add 添加任何 PPA 时,我得到此输出

  File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 380, in get_ppa_info
    ret = get_ppa_info_from_lp(user, ppa)
  File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 110, in get_ppa_info_from_lp
    return get_info_from_lp(lp_url)
  File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 104, in get_info_from_lp
    return get_info_from_https(lp_url, True)
  File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 96, in get_info_from_https
    data = func(lp_url=url, accept_json=accept_json, retry_delays=retry_delays)
  File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 139, in _get_https_content_py3
    cafile=LAUNCHPAD_PPA_CERT)
  File "/usr/lib/python3.6/urllib/request.py", line 210, in urlopen
    raise ValueError('SSL support not available')
ValueError: SSL support not available

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/add-apt-repository", line 136, in <module>
    shortcut = shortcut_handler(line)
  File "/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py", line 1020, in shortcut_handler
    ret = factory(shortcut)
  File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 469, in shortcut_handler
    return PPAShortcutHandler(shortcut)
  File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 426, in __init__
    info = get_ppa_info(self.shortcut)
  File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 392, in get_ppa_info
    _get_suggested_ppa_message(user, ppa))
  File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 349, in _get_suggested_ppa_message
    lp_user = get_info_from_lp(LAUNCHPAD_USER_API % user)
  File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 104, in get_info_from_lp
    return get_info_from_https(lp_url, True)
  File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 96, in get_info_from_https
    data = func(lp_url=url, accept_json=accept_json, retry_delays=retry_delays)
  File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 139, in _get_https_content_py3
    cafile=LAUNCHPAD_PPA_CERT)
  File "/usr/lib/python3.6/urllib/request.py", line 210, in urlopen
    raise ValueError('SSL support not available')
ValueError: SSL support not available

我认为 ssl 存在问题的另一个症状是,当我import ssl在 python2 终端中时,它可以正常工作。但在 python 3.6 中导入 ssl 会出现段错误

Python 3.6.7 (default, Oct 22 2018, 11:32:17) 
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
Segmentation fault (core dumped)

更新

当我导入任何其他模块之前sslhashlib我得到了一个不同的错误

Python 3.6.7 (default, Oct 22 2018, 11:32:17) 
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import hashlib
>>> import ssl
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.6/ssl.py", line 101, in <module>
    import _ssl             # if we can't import it, let the error propagate
ImportError: /usr/local/lib/libssl.so.1.1: version `OPENSSL_1_1_1' not found (required by /usr/lib/python3.6/lib-dynload/_ssl.cpython-36m-x86_64-linux-gnu.so)

答案1

从中删除现有的 openssl/usr/bin/openssl/usr/local/bin/openssl使用重新安装 openssl这个答案修复了这个问题。在此之前,我还按照@ByteCommander 的建议尝试了以下操作

sudo apt install --reinstall openssl
sudo apt install --reinstall code 
sudo apt install --reinstall python3-update-manager

相关内容