Skip to main content
 首页 » 编程设计

安装时 Python 测试失败

2025年04月02日15artech

我正在使用 Ubuntu 14.04 并在安装 Python 3.5.1 时,在运行 make test 后出现以下错误。

3 tests failed again: 
    test_httplib test_ssl test_urllibnet 

test_urllibnet

    test test_urllibnet failed -- Traceback (most recent call last): 
  File "/home/user/Softwares/Python-3.5.1/Lib/test/test_urllibnet.py", line 100, in test_getcode 
    self.assertEqual(code, 404) 
AssertionError: 500 != 404 

test_httplib

    test test_httplib failed -- Traceback (most recent call last): 
  File "/home/user/Softwares/Python-3.5.1/Lib/test/test_httplib.py", line 1325, in test_networked_good_cert 
    h.request('GET', '/') 
  File "/home/user/Softwares/Python-3.5.1/Lib/http/client.py", line 1083, in request 
    self._send_request(method, url, body, headers) 
  File "/home/user/Softwares/Python-3.5.1/Lib/http/client.py", line 1128, in _send_request 
    self.endheaders(body) 
  File "/home/user/Softwares/Python-3.5.1/Lib/http/client.py", line 1079, in endheaders 
    self._send_output(message_body) 
  File "/home/user/Softwares/Python-3.5.1/Lib/http/client.py", line 911, in _send_output 
    self.send(msg) 
  File "/home/user/Softwares/Python-3.5.1/Lib/http/client.py", line 854, in send 
    self.connect() 
  File "/home/user/Softwares/Python-3.5.1/Lib/http/client.py", line 1237, in connect 
    server_hostname=server_hostname) 
  File "/home/user/Softwares/Python-3.5.1/Lib/ssl.py", line 376, in wrap_socket 
    _context=self) 
  File "/home/user/Softwares/Python-3.5.1/Lib/ssl.py", line 747, in __init__ 
    self.do_handshake() 
  File "/home/user/Softwares/Python-3.5.1/Lib/ssl.py", line 983, in do_handshake 
    self._sslobj.do_handshake() 
  File "/home/user/Softwares/Python-3.5.1/Lib/ssl.py", line 628, in do_handshake 
    self._sslobj.do_handshake() 
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:645) 

test_ssl

Resource 'sha256.tbs-internet.com' is not available 
/home/user/Softwares/Python-3.5.1/Lib/unittest/case.py:628: ResourceWarning: unclosed <ssl.SSLSocket fd=4, family=AddressFamily.AF_INET, type=2049, proto=0, laddr=('192.168.0.9', 42188), raddr=('82.94.164.164', 443)> 
  outcome.errors.clear() 
/home/user/Softwares/Python-3.5.1/Lib/unittest/case.py:628: ResourceWarning: unclosed <ssl.SSLSocket fd=4, family=AddressFamily.AF_INET, type=2049, proto=0, laddr=('192.168.0.9', 42198), raddr=('82.94.164.164', 443)> 
  outcome.errors.clear() 
/home/user/Softwares/Python-3.5.1/Lib/unittest/case.py:628: ResourceWarning: unclosed <ssl.SSLSocket fd=4, family=AddressFamily.AF_INET, type=2049, proto=0, laddr=('192.168.0.9', 42213), raddr=('82.94.164.164', 443)> 
  outcome.errors.clear() 
/home/user/Softwares/Python-3.5.1/Lib/unittest/case.py:628: ResourceWarning: unclosed <socket.socket fd=4, family=AddressFamily.AF_INET, type=2049, proto=0, laddr=('192.168.0.9', 42235), raddr=('82.94.164.164', 443)> 
  outcome.errors.clear() 
test test_ssl failed -- multiple errors occurred; run in verbose mode for details 

如果我继续安装,对以后有影响吗? 这有什么原因吗?有什么解决方案可以解决这个问题吗?

谢谢

请您参考如下方法:

在我看来,您的主机的互联网连接有问题。尝试

wget http://www.google.com  

看看你是否得到任何结果。

回答:

看来我发现了问题:这是 2015 年 test.py 中的一个错误 psf.upfronthosting.co.za/issue25674我建议您从新位置获取或重新安装 Python,此错误已修复