使用python setup.py build_ext --inplace命令编译cython代码, 出现以下错误:

Compiling cython_example.pyx because it changed.
[1/1] Cythonizing cython_example.pyx
D:\python_virtualenv\bigdata\lib\site-packages\Cython\Compiler\Main.py:367: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in
a later release! File: D:\学习\bigdatalearn\cython_test\cython_example.pyx
tree = Parsing.p_module(s, pxd, full_module_name)
running build_ext
building 'cython_test.cython_example' extension
creating build
creating build\temp.win-amd64-3.6
creating build\temp.win-amd64-3.6\Release
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD "-Id:\program files\python361\include" "-Id:\program files\python361\includ
e" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits
\8.1\include\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\winrt" /Tccython_example.c /Fobuild\temp.win-amd64
-3.6\Release\cython_example.obj
cython_example.c
creating D:\学习\bigdatalearn\cython_test\cython_test
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\link.exe /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO "/LIBPATH:d:\program files\python361\
Libs" /LIBPATH:D:\python_virtualenv\bigdata\libs /LIBPATH:D:\python_virtualenv\bigdata\PCbuild\amd64 "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LIB\amd64"
"/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.10240.0\ucrt\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x64" /EXPORT:PyInit_cython_example b
uild\temp.win-amd64-3.6\Release\cython_example.obj /OUT:D:\学习\bigdatalearn\cython_test\cython_test\cython_example.cp36-win_amd64.pyd /IMPLIB:build\temp.win-amd64-3.6\Release\c
ython_example.cp36-win_amd64.lib
python36.lib(python36.dll) : fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'X86'
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\bin\\link.exe' failed with exit status 1112

解决:

  报错的意思是系统环境是64位windows系统,使用的C编译工具却是32位的。
  windows系统中'x86'表示32位。
  上面这个错的主要问题是使用的link.exe是32位的,只要改成64位的link.exe就没有问题了。
  

  环境: windows64位, python 64位, python3.6.1
  第一步:
    找到windows的系统环境变量path:
    将"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64;" 加在path最前面,这样就可以优先使用64位的link.exe。
  第二步:
    新建一个Dos窗口, 执行 "echo %PATH%" ,使环境变量立即生效。(在前面建好的DOS窗口下执行没有用)

  第三步:
    如果是在pycharm的Terminal中执行的 python setup.py build_ext --inplace命令,还需要先重启pycharm,再在其中执行编译命令才会有效。

    DOS的话新建一个DOS窗口即可。

解决了上面这个问题,又出现了一个新问题:

running build_ext
building 'cython_test.cython_example' extension
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD "-Id:\program files\python361\include" "-Id:\program files\python361\include" "-IC:\Program Files (x86)\Microsoft Visual
Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\8.1\include\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\um" "-IC:\Program Files (x
86)\Windows Kits\8.1\include\winrt" /Tccython_example.c /Fobuild\temp.win-amd64-3.6\Release\cython_example.obj
cython_example.c
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\link.exe /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO "/LIBPATH:d:\program files\python361\Libs" /LIBPATH:D:\python_virtualenv\bigdata\li
bs /LIBPATH:D:\python_virtualenv\bigdata\PCbuild\amd64 "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LIB\amd64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.10240.0\ucrt\x64" "/LIBPATH:C:\Program F
iles (x86)\Windows Kits\8.1\lib\winv6.3\um\x64" /EXPORT:PyInit_cython_example build\temp.win-amd64-3.6\Release\cython_example.obj /OUT:D:\学习\bigdatalearn\cython_test\cython_test\cython_example.cp36-win_amd64.pyd /IMPLIB:build\t
emp.win-amd64-3.6\Release\cython_example.cp36-win_amd64.lib
cython_example.obj : warning LNK4197: export 'PyInit_cython_example' specified multiple times; using first specification
Creating library build\temp.win-amd64-3.6\Release\cython_example.cp36-win_amd64.lib and object build\temp.win-amd64-3.6\Release\cython_example.cp36-win_amd64.exp
Generating code
Finished generating code
LINK : fatal error LNK1158: cannot run 'rc.exe'
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\bin\\amd64\\link.exe' failed with exit status 1158 

解决:
  错误的意思是缺少rc.exe文件,这个文件在C:\Program Files (x86)\Windows Kits\8.1\bin\x64下,只需要将该目录下的 rc.exe 和 rcdll.dll拷贝一份粘贴到link.exe所在目录C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64下即可。

  如果是32位系统,则是将C:\Program Files (x86)\Windows Kits\8.1\bin\x86下的rc.exe和rcdll.dll粘贴到C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin下。

编译Cython代码时遇到的问题: fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'X86'的更多相关文章

  1. fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'X86'

    这个问题很奇怪.原来是/machine:X86 /machine:X64这两个链接器选项一起使用了.所以就冲突了.接手别人的项目就是晕啊.不知道为什么在VS中linker commandline的ad ...

  2. C++的Public.lib(Public.dll) : fatal error LNK1112: module machine type 'X86' conflicts with target machine type 'x64'

    今天开始编译网游服务器,找前辈借来批处理文件,版本控制上拿下代码,库等一系列资源,尼玛啊,编译出错: Public.lib(Public.dll) : fatal error LNK1112: mod ...

  3. fatal error LNK1112: module machine type 'X86' conflicts with target machine type 'x64'

    xxxxxx.lib(xxxxxx.obj) : fatal error LNK1112: module machine type 'X86' conflicts with target machin ...

  4. 使用VC6.0编译C++代码的时候报错:fatal error C1071: unexpected end of file found in comment(Mark ZZ)

    fatal error C1071: unexpected end of file found in comment(Mark ZZ) 今天在一论坛上看到一人发帖: 『最近遇到一个奇怪的问题,代码中的 ...

  5. Flash调用Alchemy编译的代码时出现Error #1506的解决

    Flash调用Alchemy编译的代码时出现Error #1506的解决这个问题困扰了我很久,因为需要频繁的向Alchemy代码中传递大ByteArray数组.当某次传递的数据量较大时,后面再调用时就 ...

  6. OpenCV2.4.11+VS2012的环境配置+“fatal error LNK1112: 模块计算机类型“X86”与目标计算机类型“x64”冲突”的问题解决

    本来OpenCV环境配置的问题是个基础问题,但是步骤有点小烦,所以几乎每次都要百度一下,加上这次遇到的“fatal error LNK1112: 模块计算机类型“X86”与目标计算机类型“x64”冲突 ...

  7. [转]fatal error LNK1112: 模块计算机类型“X86”与目标计算机类型“x64”冲突

    来自--------------------- 原文:https://blog.csdn.net/qtbmp/article/details/7273191?utm_source=copy win7 ...

  8. fatal error LNK1112: 模块计算机类型“X86”与目标计算机类型“x64”冲突——我的解决方案

    本文转载于:http://blog.csdn.net/tfy1028/article/details/8660823 win7 下,安装的VS2010,然后搭配opencv2.4.3运行,报错为:fa ...

  9. fatal error U1087: cannot have : and :: dependents for same target Stop.

    转自VC错误:http://www.vcerror.com/?p=72 问题描述: 完成后编译,发现有错误  D:\WinDDK\7600.16385.1\bin\makefile.new(7117) ...

随机推荐

  1. Kafka 深入核心参数配置

    Kafka 真是一个异常稳定的组件,服务器上我们部署了 kafka_2.11-1.0.1 版本的 kafka 除了几次计算时间太长触发了 rebalance 以外,基本没有处理过什么奇怪的问题. 但是 ...

  2. 1090 Highest Price in Supply Chain (25)(25 分)

    A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone invo ...

  3. java连数据库和数据库连接池踩坑日记(二)-------数据库连接池c3p0

    关于数据库连接池,我觉得有些沮丧,因为最后被毙掉了说不用考虑多线程的问题…… 数据库连接池的推荐:https://www.cnblogs.com/nuccch/p/8120349.html 我最终选择 ...

  4. SpringData :下划线的那些破事

    今天写一个查询语句的时候,报错如下 org.springframework.beans.factory.BeanCreationException: Error creating bean with ...

  5. webpack-merge使用说明

    webpack-merge   配置分离 随着我们业务逻辑的增多,图片.字体.css.ES6以及CSS预处理器和后处理器逐渐的加入到我们的项目中来,进而导致配置文件的增多,使得配置文件书写起来比较繁琐 ...

  6. LDAP服务端 - 调研

    一.服务端实现 1.OpenLdap 2.ApacheDS 二.OpenLdap 1.https://segmentfault.com/a/1190000014683418 2.https://www ...

  7. Python在windows平台的多版本配置

    Python在windows平台的多版本配置 快速阅读: ​ python在windows平台的环境变量以及多版本配置 ,以及pycharm如何安装包,以及安装包出错时如何排查. 1.python环境 ...

  8. intellij idea tomcat 启动不生成war包

    intellij idea tomcat 启动不生成war包 想把项目打包成war包做测试,但是按照之前的方法居然没有成功导出war包,犯了很低级的错误,特此记录. (1)首先在Project Str ...

  9. Traverse an expression tree and extract parameters

    Traverse an expression tree and extract parameters   I think as you've said that using ExpressionVis ...

  10. google镜像《转》

    最新谷歌镜像列表 https://jsproxy-demo.ml 谷歌镜像F1http://go.yuxuantech.com 谷歌镜像F1,非SSLhttps://www.siwa88.net 谷歌 ...