SSL错误安装python3

问题描述:

使用我刚安装的Python: 冲泡安装python3SSL错误安装python3

我然后跑 PIP3安装的virtualenv

我得到这个错误: PIP配置与需要TLS/SSL位置但是Python中的ssl模块不可用。 收集virtualenv 无法获取URL https://pypi.python.org/simple/virtualenv/:确认SSL证书时出现问题:无法连接到HTTPS URL,因为SSL模块不可用。 - 跳过 找不到符合要求virtualenv的版本(从版本:) 未找到任何与virtualenv匹配的分配

如何解决SSL错误?

+1

你确定你正在运行与您冲泡安装python3传来PIP3?检查pip3,python3等的位置 – pvg

+0

请参阅:https://*.com/questions/41489439/pip3-installs-inside-virtual-environment-with-python3-6-failing-due-to-ssl- modul/42798679 – alexisdevarennes

+0

@pvg我检查了python3在这里: sys.path = [ '/ Users/bootadmin', '/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6 /lib/python36.zip', '/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6', '/ usr/local/Cellar/python3 /3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/lib-dynload', '/usr/local/lib/python3.6/site-packages', '/ usr/local /Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages', ] 我不知道如何找到pip3目录 –

似乎酿造跳过了证明步骤。

从我的本地安装复制,这将运行证书安装步骤。

brew install openssl 
ln -s /usr/local/Cellar/openssl/{version}/include/openssl /usr/bin/openssl 
pip install certifi 

然后运行这个命令:

# install_certifi.py 
# 
# sample script to install or update a set of default Root Certificates 
# for the ssl module. Uses the certificates provided by the certifi package: 
#  https://pypi.python.org/pypi/certifi 

import os 
import os.path 
import ssl 
import stat 
import subprocess 
import sys 

STAT_0o775 = (stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR 
      | stat.S_IRGRP | stat.S_IWGRP | stat.S_IXGRP 
      | stat.S_IROTH |    stat.S_IXOTH) 


def main(): 
    openssl_dir, openssl_cafile = os.path.split(
     ssl.get_default_verify_paths().openssl_cafile) 

    print(" -- pip install --upgrade certifi") 
    subprocess.check_call([sys.executable, 
     "-E", "-s", "-m", "pip", "install", "--upgrade", "certifi"]) 

    import certifi 

    # change working directory to the default SSL directory 
    os.chdir(openssl_dir) 
    relpath_to_certifi_cafile = os.path.relpath(certifi.where()) 
    print(" -- removing any existing file or link") 
    try: 
     os.remove(openssl_cafile) 
    except FileNotFoundError: 
     pass 
    print(" -- creating symlink to certifi certificate bundle") 
    os.symlink(relpath_to_certifi_cafile, openssl_cafile) 
    print(" -- setting permissions") 
    os.chmod(openssl_cafile, STAT_0o775) 
    print(" -- update complete") 

if __name__ == '__main__': 
    main() 
+0

我跑的代码,并得到这个错误: F:编程bootadmin $ python3 test.py 回溯(最近通话最后一个): 文件 “test.py”,9号线,在 进口SSL 文件“/ USR /local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py“,第101行,在 import _ssl#如果我们无法导入它,让错误传播 ImportError:dlopen(/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/lib-dynload/_ssl.cpython-36m-darwin.so ,2):Library not loaded:/usr/local/opt/openssl/lib/libssl.1.0.0.dylib –

+0

哪个错误?你运行pip install certifi和brew安装openssl吗? – alexisdevarennes

+0

YUP运行brew安装openssl :) – alexisdevarennes