首页 > 解决方案 > python openssl:如何在搅拌机中安装插件时升级 openssl 版本

问题描述

我有这个插件,我想安装,但不知何故,安装总是由于错误而中断:

urllib.error.URLError: <urlopen error [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:720)>

所以我认为问题可能是SSL版本太旧,所以我将版本信息打印出来:

OpenSSL 0.9.8zh 14 Jan 2016

在看到一些答案后,在此处输入链接描述,在此处输入链接描述,在此处输入链接描述现在我的 Mac 上有最新的 SSL,但似乎这个插件使用了一些未安装在我的磁盘上的外部 python,并且这个 python 总是尝试使用它自己的 SSL。我找到了blender使用的这个python,Show Package Contents -> Burrow down to Contents -> Resources -> 2.79 -> python,好像是python 3.5,我在磁盘上安装了python 3.7。

下面是插件的安装代码:

import bpy
import os
import addon_utils

from subprocess import call

from urllib.request import urlretrieve

from zipfile import ZipFile
from tempfile import TemporaryDirectory
from shutil import copytree,rmtree
from os.path import join


python_exec = bpy.app.binary_path_python
path_to_addons = bpy.utils.user_resource('SCRIPTS', "addons")

print('Install Pip')

try: 
    import pip
except:
    rc = call([python_exec,"-m","ensurepip","--default-pip", "--upgrade"])
    import pip

print('Download RD')

import ssl
print(ssl.OPENSSL_VERSION)

URL = "https://github.com/HBPNeurorobotics/BlenderRobotDesigner/archive/master.zip"
addon_dir = 'robot_designer_plugin'
zip_dir = "BlenderRobotDesigner-master"

print('Unzip RD')
with TemporaryDirectory() as tmp:
    zip_file = join(tmp,"master.zip")

    print(zip_file)
    urlretrieve(URL,zip_file)
    print('Downloaded!')

    rc = call([python_exec,"-m","zipfile","-e",zip_file,tmp])

    with ZipFile(zip_file, "r") as z:
        z.extractall(tmp)

    print('Unzip finished')
    addon_dir_src = join(tmp,zip_dir,addon_dir)
    addon_dir_dst = join(path_to_addons,addon_dir)

    print('remove previous addon')
    rmtree(addon_dir_dst,True)

    print('add latest addon')
    copytree(addon_dir_src,addon_dir_dst)

    print('enable addon')
    addon_utils.enable("robot_designer_plugin", persistent=True)
    bpy.ops.wm.save_userpref()

    with open(join(addon_dir_src,"requirements.txt")) as f:
        for line in f:
            rc = call([python_exec,"-m","pip","install",line])
            #pip.main(['install', line])
print('RD Installation Done!')

这是终端中引发的错误:

Install Pip
Download RD
OpenSSL 0.9.8zh 14 Jan 2016
Unzip RD
/var/folders/nm/9nfcg98x4hxf1kh08dj8p92h0000gn/T/tmpvd4k0lfi/master.zip
Traceback (most recent call last):
  File "/Applications/Blender/blender.app/Contents/Resources/2.79/python/lib/python3.5/urllib/request.py", line 1254, in do_open
    h.request(req.get_method(), req.selector, req.data, headers)
  File "/Applications/Blender/blender.app/Contents/Resources/2.79/python/lib/python3.5/http/client.py", line 1107, in request
    self._send_request(method, url, body, headers)
  File "/Applications/Blender/blender.app/Contents/Resources/2.79/python/lib/python3.5/http/client.py", line 1152, in _send_request
    self.endheaders(body)
  File "/Applications/Blender/blender.app/Contents/Resources/2.79/python/lib/python3.5/http/client.py", line 1103, in endheaders
    self._send_output(message_body)
  File "/Applications/Blender/blender.app/Contents/Resources/2.79/python/lib/python3.5/http/client.py", line 934, in _send_output
    self.send(msg)
  File "/Applications/Blender/blender.app/Contents/Resources/2.79/python/lib/python3.5/http/client.py", line 877, in send
    self.connect()
  File "/Applications/Blender/blender.app/Contents/Resources/2.79/python/lib/python3.5/http/client.py", line 1261, in connect
    server_hostname=server_hostname)
  File "/Applications/Blender/blender.app/Contents/Resources/2.79/python/lib/python3.5/ssl.py", line 385, in wrap_socket
    _context=self)
  File "/Applications/Blender/blender.app/Contents/Resources/2.79/python/lib/python3.5/ssl.py", line 760, in __init__
    self.do_handshake()
  File "/Applications/Blender/blender.app/Contents/Resources/2.79/python/lib/python3.5/ssl.py", line 996, in do_handshake
    self._sslobj.do_handshake()
  File "/Applications/Blender/blender.app/Contents/Resources/2.79/python/lib/python3.5/ssl.py", line 641, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLError: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:720)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/gaoyingqiang/Downloads/installer.blend/Text", line 40, in <module>
  File "/Applications/Blender/blender.app/Contents/Resources/2.79/python/lib/python3.5/urllib/request.py", line 188, in urlretrieve
    with contextlib.closing(urlopen(url, data)) as fp:
  File "/Applications/Blender/blender.app/Contents/Resources/2.79/python/lib/python3.5/urllib/request.py", line 163, in urlopen
    return opener.open(url, data, timeout)
  File "/Applications/Blender/blender.app/Contents/Resources/2.79/python/lib/python3.5/urllib/request.py", line 466, in open
    response = self._open(req, data)
  File "/Applications/Blender/blender.app/Contents/Resources/2.79/python/lib/python3.5/urllib/request.py", line 484, in _open
    '_open', req)
  File "/Applications/Blender/blender.app/Contents/Resources/2.79/python/lib/python3.5/urllib/request.py", line 444, in _call_chain
    result = func(*args)
  File "/Applications/Blender/blender.app/Contents/Resources/2.79/python/lib/python3.5/urllib/request.py", line 1297, in https_open
    context=self._context, check_hostname=self._check_hostname)
  File "/Applications/Blender/blender.app/Contents/Resources/2.79/python/lib/python3.5/urllib/request.py", line 1256, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:720)>
Error: Python script fail, look in the console for now...

我真的不知道哪里出了问题,因为插件没有提供关于这个问题的进一步信息。我怎样才能解决这个问题?

新版本:

我现在想解决如何在 Blender 中的 python 中升级 openssl 版本的问题。Blender 带来了 python3.5,我怎么能brew install openssl到这个 python 而不是我磁盘上的 python?

标签: pythonsslopensslblender

解决方案


推荐阅读