无法在 Windows 8.1 64 位机器中安装 M2Crypto 包

Unable to install M2Crypto package in Windows 8.1 64 bit machine

我正在使用安装了 Python 2.7 的 Win8.1 64 位机器。我已经安装了 swigwin 3.0.5。当我执行 "pip install M2Crypto" 时,出现以下错误:

SWIG\_m2crypto.i(30) : Error: Unable to find 'openssl\opensslv.h'

SWIG\_m2crypto.i(33) : Error: Unable to find 'openssl\safestack.h'

SWIG\_evp.i(12) : Error: Unable to find 'openssl\opensslconf.h'

SWIG\_ec.i(7) : Error: Unable to find 'openssl\o,pensslconf.h'

在某些链接中,我发现建议是安装 openssl-dev。但是我找不到 windows 的等效包(pip install openssl-dev 不起作用,我已经完成了 pip install pyOpenSSL 但对我没有帮助)。

提前致谢。

在 Windows 上安装 M2Crypto 很痛苦。幸运的是,有些人已经努力为 M2Crypto 创建 Windows 个安装程序:

您也可以直接从 M2Crypto 的制造商那里使用稍旧版本的软件包,因为他们实际上提供了一段时间的 Windows 可安装版本:

这也很有用link:

我通过以下方式解决了这个问题(在 Windows 上的 MiniConda 安装中):

  1. conda 安装 openssl
  2. 复制\envs\<环境>\Library\include\openssl到\envs\<环境>\include\openssl(或mklink)

它可能也适用于其他 Python 环境。

但是,我 运行 遇到了更多问题(我不知道如何解决):

    building 'M2Crypto.__m2crypto' extension
    swigging SWIG/_m2crypto.i to SWIG/_m2crypto_wrap.c
    C:\Program Files\MiniConda3\envs\python2\Library\bin\swig.exe -python "-IC:\Program Files\MiniConda3\envs\python2\include" "-IC:\Program Files\MiniConda3\envs\python2\PC" -Ic:\pkg\include -include
all -modern -builtin -outdir build\lib.win-amd64-2.7\M2Crypto -o SWIG/_m2crypto_wrap.c SWIG/_m2crypto.i
    SWIG\_bio.i(64) : Warning 454: Setting a pointer/reference variable may leak memory.
    SWIG\_rand.i(23) : Warning 454: Setting a pointer/reference variable may leak memory.
    SWIG\_evp.i(180) : Warning 454: Setting a pointer/reference variable may leak memory.
    SWIG\_dh.i(36) : Warning 454: Setting a pointer/reference variable may leak memory.
    SWIG\_rsa.i(43) : Warning 454: Setting a pointer/reference variable may leak memory.
    SWIG\_dsa.i(31) : Warning 454: Setting a pointer/reference variable may leak memory.
    SWIG\_ssl.i(241) : Warning 454: Setting a pointer/reference variable may leak memory.
    SWIG\_ssl.i(242) : Warning 454: Setting a pointer/reference variable may leak memory.
    SWIG\_x509.i(332) : Warning 454: Setting a pointer/reference variable may leak memory.
    SWIG\_pkcs7.i(44) : Warning 454: Setting a pointer/reference variable may leak memory.
    SWIG\_pkcs7.i(44) : Warning 454: Setting a pointer/reference variable may leak memory.
    SWIG\_util.i(11) : Warning 454: Setting a pointer/reference variable may leak memory.
    SWIG\_ec.i(111) : Warning 454: Setting a pointer/reference variable may leak memory.
    SWIG\_engine.i(168) : Warning 454: Setting a pointer/reference variable may leak memory.
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "c:\users\pal\appdata\local\temp\pip-build-reeqlh\M2Crypto\setup.py", line 280, in <module>
        'clean': Clean
      File "C:\Program Files\MiniConda3\envs\python2\lib\distutils\core.py", line 151, in setup
        dist.run_commands()
      File "C:\Program Files\MiniConda3\envs\python2\lib\distutils\dist.py", line 953, in run_commands
        self.run_command(cmd)
      File "C:\Program Files\MiniConda3\envs\python2\lib\distutils\dist.py", line 972, in run_command
        cmd_obj.run()
      File "C:\Program Files\MiniConda3\envs\python2\lib\site-packages\setuptools\command\install.py", line 53, in run
        return _install.run(self)
      File "C:\Program Files\MiniConda3\envs\python2\lib\distutils\command\install.py", line 563, in run
        self.run_command('build')
      File "C:\Program Files\MiniConda3\envs\python2\lib\distutils\cmd.py", line 326, in run_command
        self.distribution.run_command(command)
      File "C:\Program Files\MiniConda3\envs\python2\lib\distutils\dist.py", line 972, in run_command
        cmd_obj.run()
      File "C:\Program Files\MiniConda3\envs\python2\lib\distutils\command\build.py", line 127, in run
        self.run_command(cmd_name)
      File "C:\Program Files\MiniConda3\envs\python2\lib\distutils\cmd.py", line 326, in run_command
        self.distribution.run_command(command)
      File "C:\Program Files\MiniConda3\envs\python2\lib\distutils\dist.py", line 972, in run_command
        cmd_obj.run()
      File "c:\users\pal\appdata\local\temp\pip-build-reeqlh\M2Crypto\setup.py", line 148, in run
        build_ext.build_ext.run(self)
      File "C:\Program Files\MiniConda3\envs\python2\lib\site-packages\setuptools\command\build_ext.py", line 46, in run
        _build_ext.run(self)
      File "C:\Program Files\MiniConda3\envs\python2\lib\distutils\command\build_ext.py", line 339, in run
        self.build_extensions()
      File "C:\Program Files\MiniConda3\envs\python2\lib\distutils\command\build_ext.py", line 448, in build_extensions
        self.build_extension(ext)
      File "C:\Program Files\MiniConda3\envs\python2\lib\site-packages\setuptools\command\build_ext.py", line 182, in build_extension
        _build_ext.build_extension(self,ext)
      File "C:\Program Files\MiniConda3\envs\python2\lib\distutils\command\build_ext.py", line 498, in build_extension
        depends=ext.depends)
      File "C:\Program Files\MiniConda3\envs\python2\lib\distutils\msvc9compiler.py", line 473, in compile
        self.initialize()
      File "C:\Program Files\MiniConda3\envs\python2\lib\distutils\msvc9compiler.py", line 383, in initialize
        vc_env = query_vcvarsall(VERSION, plat_spec)
      File "C:\Program Files\MiniConda3\envs\python2\lib\distutils\msvc9compiler.py", line 299, in query_vcvarsall
        raise ValueError(str(list(result.keys())))
    ValueError: [u'path']

    ----------------------------------------
Command ""C:\Program Files\MiniConda3\envs\python2\python.exe" -u -c "import setuptools, tokenize;__file__='c:\users\pal\appdata\local\temp\pip-build-reeqlh\M2Crypto\setup.py';exec(compile(get
attr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record c:\users\pal\appdata\local\temp\pip-opk8he-record\install-record.txt --single-version-external
ly-managed --compile" failed with error code 1 in c:\users\pal\appdata\local\temp\pip-build-reeqlh\M2Crypto\