实例化virtualenv的时候又遇到这个问题

来源:1-1 课程介绍

慕用8401734

2022-07-16

按这个链接操作了一下,还有有问题,我试了3个版本都遇到同样的问题(CentOS(7.9, 7.6, 7.4)),而且都是围绕着ssl的,

  1. 编译阶段遇到的ssl问题
    Message: 'späm’
    Arguments: ()
    Got an error:
    [SSL: SSLV3_ALERT_CERTIFICATE_EXPIRED] sslv3 alert certificate expired (_ssl.c:833)
    然后我用这串命令流重现安装了ssl证书,编译阶段是ssl问题就解决了
    cd /usr/local/src
    wget https://www.openssl.org/source/openssl-1.1.1k.tar.gz
    tar -xf openssl-1.1.1k.tar.gz
    cd openssl-1.1.1k
    ./config --prefix=/usr/local/openssl shared zlib &&make && make install
    mv /usr/bin/openssl /usr/bin/openssl.bak
    mv /usr/include/openssl /usr/include/openssl.bak
    ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
    ln -s /usr/local/openssl/include/openssl /usr/include/openssl
    echo /usr/local/openssl/lib >> /etc/ld.so.conf
    ldconfig -v
    openssl version
    ln -s /usr/local/openssl/lib/libssl.so.1.1 /usr/lib64/libssl.so.1.1
    ln -s /usr/local/openssl/lib/libcrypto.so.1.1 /usr/lib64/libcrypto.so.1.1

  2. pip install virtualenv 是遇到这个问题
    [root@localhost Python-3.6.5]# pip3.6 install virtualenv
    pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
    Collecting virtualenv
    Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘SSLError(“Can’t connect to HTTPS URL because the SSL module is not available.”,)’: /simple/virtualenv/
    Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘SSLError(“Can’t connect to HTTPS URL because the SSL module is not available.”,)’: /simple/virtualenv/
    Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘SSLError(“Can’t connect to HTTPS URL because the SSL module is not available.”,)’: /simple/virtualenv/
    Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘SSLError(“Can’t connect to HTTPS URL because the SSL module is not available.”,)’: /simple/virtualenv/
    Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘SSLError(“Can’t connect to HTTPS URL because the SSL module is not available.”,)’: /simple/virtualenv/
    Could not fetch URL https://pypi.python.org/simple/virtualenv/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host=‘pypi.python.org’, port=443): Max retries exceeded with url: /simple/virtualenv/ (Caused by SSLError(“Can’t connect to HTTPS URL because the SSL module is not available.”,)) - skipping
    Could not find a version that satisfies the requirement virtualenv (from versions: )
    No matching distribution found for virtualenv
    [root@localhost Python-3.6.5]#
    然后我用下面命令流解决了这个问题
    mkdir ~/.pip
    vim ~/.pip/pip.conf
    [global]
    index-url=http://mirrors.aliyun.com/pypi/simple/
    [install]
    trusted-host=mirrors.aliyun.com

  3. 然后实例化virtualenv的时候又遇到这个问题
    [deploy@localhost ~]$ virtualenv -p /usr/local/bin/python3.6 .py3-a2.5-env
    Traceback (most recent call last):
    File “/usr/local/bin/virtualenv”, line 7, in
    from virtualenv.main import run_with_catch
    File “/usr/local/lib/python3.6/site-packages/virtualenv/init.py”, line 3, in
    from .run import cli_run, session_via_cli
    File “/usr/local/lib/python3.6/site-packages/virtualenv/run/init.py”, line 11, in
    from …seed.wheels.periodic_update import manual_upgrade
    File “/usr/local/lib/python3.6/site-packages/virtualenv/seed/wheels/init.py”, line 3, in
    from .acquire import get_wheel, pip_wheel_env_run
    File “/usr/local/lib/python3.6/site-packages/virtualenv/seed/wheels/acquire.py”, line 12, in
    from .bundle import from_bundle
    File “/usr/local/lib/python3.6/site-packages/virtualenv/seed/wheels/bundle.py”, line 4, in
    from .periodic_update import periodic_update
    File “/usr/local/lib/python3.6/site-packages/virtualenv/seed/wheels/periodic_update.py”, line 10, in
    import ssl
    File “/usr/local/lib/python3.6/ssl.py”, line 101, in
    import _ssl # if we can’t import it, let the error propagate
    ModuleNotFoundError: No module named ‘_ssl’
    [deploy@localhost ~]$
    好艰难啊!

写回答

1回答

一路向北

2022-07-23

ceotos目前官方已经停止更新,它涉及到的证书估计会出问题。
建议换成ubuntu系统 尝试重复安装
0
0

Jenkins+Ansible+Gitlab-三剑合璧掌握自动化部署

整合三大工具解决自动化部署&持续交付问题

1290 学习 · 319 问题

查看课程