python openssl:在Blender中安装插件时如何升级openssl版本

时间:2018-11-03 19:44:37

标签: python ssl openssl blender

我有要安装的插件,但是由于错误,安装总是会中断:

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

在看到一些答案之后,enter link description hereenter link description hereenter link description here现在我的Mac上拥有最新的SSL,但似乎此插件正在使用一些外部python,但没有安装在我的磁盘上,并且此python始终尝试使用自己的SSL。我发现了Blender使用的这个python,显示软件包的内容->浏览至目录->资源-> 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,但没有<math.h>到磁盘上的python?

0 个答案:

没有答案