使用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. Unity 3d 实现物体跟随摄像机视野运动

    https://blog.csdn.net/qq_31411825/article/details/61623857 Unity 3d 实现物体跟随摄像机视野运动Created by miccall ...

  2. LOJ6071. 「2017 山东一轮集训 Day5」字符串 [SAM]

    LOJ 思路 这种计数题显然是要先把每一个合法的串用唯一的方法表示出来.(我连这都没想到真是无可救药了) 如何唯一?容易想到把前缀尽可能多地在第一个串填掉,然后填第二个,第三个-- 如何做到这样?可以 ...

  3. JSP简单标签的开发

    1. 新建RepeatSampleTag类,代码如下: package bid.zhazhapan.fims.tag; import java.io.IOException; import java. ...

  4. Connection: close

    在http1.1中request和reponse header中都有可能出现一个connection头字段,此header的含义是当client和server通信时对于长链接如何进行处理. 在http ...

  5. CF1205题解

    B 最高有\(64\)位,当\(n\le 128\)时,最坏情况形成不了三元环,\(floyed\)暴力做 否则直接输出\(3\) C 题意的\(n\)均为奇数,设\((i,j)\),把\(i+j\) ...

  6. Hadoop hadoop 机架感知配置

    机架感知脚本 使用python3编写机架感知脚本,报存到topology.py,给予执行权限 import sys import os DEFAULT_RACK="/default-rack ...

  7. ICEM——倒角的处理

    原视频下载地址: https://pan.baidu.com/s/1miHMOuk 密码: knc4

  8. 三大框架 之 Spring(IOC控制反转、DI依赖注入)

    目录 常用词汇 left join与left outer join的区别 Struts2的标签库导入 Spring Spring概述 什么是Spring spring特点 下载 IOC 什么IOC 传 ...

  9. html5中progress/meter元素

    html5中progress/meter元素 一.总结 一句话总结: progress元素:用来建立一个进度条 meter元素的作用:用来建立一个度量条,用来表示度量衡的评定 <progress ...

  10. 【内功修炼】"裁员潮",“中年危机”,该如何战胜你的焦虑

    "裁员"."中年危机"这些曾经看上去比较遥远的词汇,最近开始频繁出现在各种文章和新闻中,个人觉得这主要由两方面原因造成: 近两年,国内外经济形势严峻(更有经济学 ...