【问题标题】:Can't install pycrypto on windows virtualenv无法在 windows virtualenv 上安装 pycrypto
【发布时间】:2013-09-04 11:36:21
【问题描述】:

我正在尝试在我的 Windows 机器上安装 pycrypto。我已经安装了 mingw 并且 distutils 正在使用它。这里的错误是我得到的:

In file included from C:\Python27\include/pyconfig.h:68:0,

from C:\Python27\include/Python.h:8,

from src/winrand.c:33:

c:\mingw\bin../lib/gcc/mingw32/4.7.2/../../../../include/io.h:301:1: error: unknown type name 'off64_t'

c:\mingw\bin../lib/gcc/mingw32/4.7.2/../../../../include/io.h:301:36: error: unknown type name 'off64_t'

c:\mingw\bin../lib/gcc/mingw32/4.7.2/../../../../include/io.h:302:1: error: unknown type name 'off64_t'

c:\mingw\bin../lib/gcc/mingw32/4.7.2/../../../../include/io.h:302:39: error: unknown type name 'off64_t'

src/winrand.c:38:0: warning: "_WIN32_WINNT" redefined [enabled by default]

In file included from c:\mingw\bin../lib/gcc/mingw32/4.7.2/../../../../include/_mingw.h:35:0,

from c:\mingw\bin../lib/gcc/mingw32/4.7.2/../../../../include/io.h:27,

from C:\Python27\include/pyconfig.h:68,

from C:\Python27\include/Python.h:8,

from src/winrand.c:33:

c:\mingw\bin../lib/gcc/mingw32/4.7.2/../../../../include/sdkddkver.h:154:0: note: this is the location of the previous definition

error: command 'gcc' failed with exit status 1

编辑:我找到了这个,但我不确定如何用它修复 pip install 。 http://ac-archive.sourceforge.net/largefile/largefiles_win32.print.html

【问题讨论】:

  • 这可能是 32 位与 64 位的问题,因为您以某种方式将两者混合在一起?
  • 我一开始也是这么想的,所以我擦了整台电脑,重新开始,只选择了 32 位的项目。
  • 您不使用voidspace.org.uk/python/modules.shtml#pycrypto的任何原因?
  • 我正在使用 virtualenv 安装。即使我使用了预编译的包,也无法解释这个错误。另一个包也可能发生。

标签: python windows pycrypto


【解决方案1】:

我在 windows 中构建 Fabric 时遇到了同样的问题。 原因是在构建 pycrypto 时 mingw32 的 gcc 配置。 在configure 中,gcc 的设置-std 设置为c99。 但是,当 -std 为 c99 时,定义了 __STRICT_ANSI__ 并跳过了 "sys/types.h" 中的 typedef _off_t off_t 和 _off64_t off64_t。 我通过修改 mingw32 中的 sys/types.h 成功构建了 pycrypto,但这很残酷。

【讨论】:

    【解决方案2】:
    1. 创建一个virtualenv(我一般都放在桌面上)

    2. 下载 pycrypto 的二进制文件(匹配您安装的 python 版本和架构 - 目前不支持 python3) - http://www.voidspace.org.uk/python/modules.shtml

    3. 导航到您创建的 virtualenv 文件夹中的 easy_install 可执行文件(在 Lib\site-packages 下)并运行 pycrypto 安装:easy_install C:\path\to\the\download\pycrypto-2.6.win-amd64-py2.7.exe

    【讨论】:

      猜你喜欢
      • 2014-07-10
      • 2020-03-27
      • 2012-07-09
      • 2011-06-22
      • 2015-01-27
      • 1970-01-01
      • 2012-11-27
      • 1970-01-01
      • 2010-12-13
      相关资源
      最近更新 更多