安装python setuptools时出现错误,编译pyOpenSSL失败

1 投票
2 回答
550 浏览
提问于 2025-04-17 21:57

我想使用pyOpenSSL,这个我已经下载并尝试构建过,但在使用setuptools的时候遇到了问题。首先,我下载了Python 2.7.6,但没有成功。后来我又试了WinPython,结果还是一样:

    Traceback (most recent call last):
  File "setup.py", line 11, in <module>
    from setuptools import setup
  File "C:\Users\User\Downloads\WinPython-32bit-2.7.6.3\python-2.7.6\lib\site-packages\setuptools\__init_
_.py", line 11, in <module>
    from setuptools.extension import Extension
  File "C:\Users\User\Downloads\WinPython-32bit-2.7.6.3\python-2.7.6\lib\site-packages\setuptools\extensi
on.py", line 5, in <module>
    from setuptools.dist import _get_unpatched
  File "C:\Users\User\Downloads\WinPython-32bit-2.7.6.3\python-2.7.6\lib\site-packages\setuptools\dist.py
", line 15, in <module>
    from setuptools.compat import numeric_types, basestring
  File "C:\Users\User\Downloads\WinPython-32bit-2.7.6.3\python-2.7.6\lib\site-packages\setuptools\compat.
py", line 19, in <module>
    from SimpleHTTPServer import SimpleHTTPRequestHandler
  File "C:\Users\User\Downloads\WinPython-32bit-2.7.6.3\python-2.7.6\lib\SimpleHTTPServer.py", line 27, i
n <module>
    class SimpleHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
  File "C:\Users\User\Downloads\WinPython-32bit-2.7.6.3\python-2.7.6\lib\SimpleHTTPServer.py", line 208,
in SimpleHTTPRequestHandler
    mimetypes.init() # try to read system mime.types
  File "C:\Users\User\Downloads\WinPython-32bit-2.7.6.3\python-2.7.6\lib\mimetypes.py", line 358, in init

    db.read_windows_registry()
  File "C:\Users\User\Downloads\WinPython-32bit-2.7.6.3\python-2.7.6\lib\mimetypes.py", line 260, in read
_windows_registry
    with _winreg.OpenKey(hkcr, subkeyname) as subkey:
TypeError: must be string without null bytes or None, not str

我在PyCharm里安装了Python 2.7.6,但还是没成功,使用WinPython也遇到了同样的问题。我现在是在Windows 7 64位系统上。

2 个回答

1

这段话是说关于Python 2.7.6的一个问题,跟Windows注册表损坏有关。

有些程序(错误地)在注册表条目中写入了一个结束的空字符,这样就搞坏了setuptools。更新Python可以解决这个问题。

可以查看这篇博客了解更多。

1

因为你在安装setuptools的时候遇到了问题,你可以从这个链接下载setuptools的Windows二进制文件。这个网站是一个很棒的资源,里面有各种Python模块的预编译Windows版本。

如果你不一定要安装64位的Python,我建议你安装32位的Python和其他模块。

撰写回答