我安装了python3.6.5 @ centOS 7并进行了正确的安装。但是当我测试urlopen时,它会在下面引发错误:
e*urllib.error.URLError: <urlopen error unknown url type: https>*
我怀疑它可能与https有关,并且我再次确认我已经安装了openssl -> zlib-dev1
有人建议吗?谢谢
python3代码:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import urllib.request
x = urllib.request.urlopen('https://www.google.com/')
print(x.read())
完整错误: ./url_test.py
Traceback (most recent call last):
File "./url_test.py", line 6, in <module>
x = urllib.request.urlopen('https://www.google.com/')
File "/usr/local/lib/python3.6/urllib/request.py", line 223, in urlopen
return opener.open(url, data, timeout)
File "/usr/local/lib/python3.6/urllib/request.py", line 526, in open
response = self._open(req, data)
File "/usr/local/lib/python3.6/urllib/request.py", line 549, in _open
'unknown_open', req)
File "/usr/local/lib/python3.6/urllib/request.py", line 504, in _ca`enter code here`ll_chain
result = func(*args)
File "/usr/local/lib/python3.6/urllib/request.py", line 1388, in unknown_open
raise URLError('unknown url type: %s' % type)
urllib.error.URLError: <urlopen error unknown url type: https>
答案 0 :(得分:0)
最后我弄清楚是什么原因引起的。它由openssl-devel引起,我没有安装它。
sudo yum install openssl-devel
完成安装后。仔细检查
yum list installed|grep openssl
openssl-devel.x86_64 1:1.0.2k-12.el7 @rhui-REGION-rhel-server-releases
翻拍
./configure
make
再次测试。完成
答案 1 :(得分:0)
我在安装诗歌时遇到了同样的问题。只需复制这两个 dll
文件
libcrypto-1_1-x64.dll
libssl-1_1-x64.dll
从 ..\Anaconda3\Library\bin
到 ..\Anaconda3\DLLs directory
。