我正在尝试通过pip在新安装的line-profiler上安装python扩展Anaconda3。由于包需要编译器,我已经安装了2019和Windows10SDK。特别是,我已经安装了
Vs2019 C++-x64/x86-Buildtools (v14.27)
我正在开发64位Windows 10,构建18363.1082。
为了确保找到所需的所有编译器文件,我在PATH环境变量中添加了以下条目:
\程序文件(x86)\Windows Kits\10\Lib\10.0.18362.0\um\x64
现在当我跑
pip install line-profiler我得到了错误信息
fatal error LNK1104: file "kernel32.lib" cannot be opened尽管文件kernel32.lib明显存在于添加到上面路径的一个文件夹中。(问题结尾处的完整错误日志)
经过一些研究,我发现在VS 2019的Developer Command提示符中操作可以帮助解决这个问题,因为它在启动时加载了一些批处理文件。因此,我打开了这个命令提示符,激活了我的Anaconda环境,并再次运行了相同的命令。现在我知道错误了
fatal error LNK1112: machine type "x64" is in confilict with the target machine type "x86".如何设置VS以正确编译扩展?特别是,我想知道
kernel32.lib?以下是完整的错误消息(必要时可免费从德语翻译)
ERROR: Command errored out with exit status 1:
command: 'C:\Users\user\Anaconda3\python.exe' 'C:\Users\user\Anaconda3\lib\site-packages\pip\_vendor\pep517\_in_process.py' build_wheel 'C:\Users\user\AppData\Local\Temp\tmpvbz5hf82'
cwd: C:\Users\user\AppData\Local\Temp\pip-install-vluz_z60\line-profiler
Complete output (217 lines):
Not searching for unused variables given on the command line.
-- The C compiler identification is MSVC 19.27.29112.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.27.29110/bin/Hostx64/x64/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.27.29110/bin/Hostx64/x64/cl.exe - broken
CMake Error at C:/Users/user/AppData/Local/Temp/pip-build-env-bxchh6aq/overlay/Lib/site-packages/cmake/data/share/cmake-3.18/Modules/CMakeTestCCompiler.cmake:66 (message):
The C compiler
"C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.27.29110/bin/Hostx64/x64/cl.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/Users/user/AppData/Local/Temp/pip-install-vluz_z60/line-profiler/_cmake_test_compile/build/CMakeFiles/CMakeTmp
Run Build Command(s):C:/Users/user/AppData/Local/Temp/pip-build-env-bxchh6aq/overlay/Scripts/ninja.exe cmTC_9b999 && [1/2] Building C object CMakeFiles\cmTC_9b999.dir\testCCompiler.c.obj
[2/2] Linking C executable cmTC_9b999.exe
FAILED: cmTC_9b999.exe
cmd.exe /C "cd . && C:\Users\user\AppData\Local\Temp\pip-build-env-bxchh6aq\overlay\Lib\site-packages\cmake\data\bin\cmake.exe -E vs_link_exe --intdir=CMakeFiles\cmTC_9b999.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100183~1.0\x64\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100183~1.0\x64\mt.exe --manifests -- C:\PROGRA~2\MICROS~3\2019\BUILDT~1\VC\Tools\MSVC\1427~1.291\bin\Hostx64\x64\link.exe /nologo CMakeFiles\cmTC_9b999.dir\testCCompiler.c.obj /out:cmTC_9b999.exe /implib:cmTC_9b999.lib /pdb:cmTC_9b999.pdb /version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:console kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && cd ."
LINK Pass 1: command "C:\PROGRA~2\MICROS~3\2019\BUILDT~1\VC\Tools\MSVC\1427~1.291\bin\Hostx64\x64\link.exe /nologo CMakeFiles\cmTC_9b999.dir\testCCompiler.c.obj /out:cmTC_9b999.exe /implib:cmTC_9b999.lib /pdb:cmTC_9b999.pdb /version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:console kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:CMakeFiles\cmTC_9b999.dir/intermediate.manifest CMakeFiles\cmTC_9b999.dir/manifest.res" failed (exit code 1104) with the following output:
LINK : fatal error LNK1104: Datei "kernel32.lib" kann nicht geöffnet werden.
ninja: build stopped: subcommand failed.FAILED: line_profiler/_line_profiler.cp38-win_amd64.pyd
cmd.exe /C "cd . && C:\Users\user\AppData\Local\Temp\pip-build-env-mf957mv5\overlay\Lib\site-packages\cmake\data\bin\cmake.exe -E vs_link_dll --intdir=line_profiler\CMakeFiles\_line_profiler.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100183~1.0\x86\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100183~1.0\x86\mt.exe --manifests -- C:\PROGRA~2\MICROS~3\2019\BUILDT~1\VC\Tools\MSVC\1427~1.291\bin\Hostx86\x86\link.exe /nologo line_profiler\CMakeFiles\_line_profiler.dir\_line_profiler.c.obj line_profiler\CMakeFiles\_line_profiler.dir\unset_trace.c.obj line_profiler\CMakeFiles\_line_profiler.dir\timers.c.obj /out:line_profiler\_line_profiler.cp38-win_amd64.pyd /implib:line_profiler\_line_profiler.lib /pdb:line_profiler\_line_profiler.pdb /dll /version:0.0 /machine:X86 /INCREMENTAL:NO /EXPORT:PyInit__line_profiler C:\Users\user\Anaconda3\libs\python38.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && cd ."
LINK: command "C:\PROGRA~2\MICROS~3\2019\BUILDT~1\VC\Tools\MSVC\1427~1.291\bin\Hostx86\x86\link.exe /nologo line_profiler\CMakeFiles\_line_profiler.dir\_line_profiler.c.obj line_profiler\CMakeFiles\_line_profiler.dir\unset_trace.c.obj line_profiler\CMakeFiles\_line_profiler.dir\timers.c.obj /out:line_profiler\_line_profiler.cp38-win_amd64.pyd /implib:line_profiler\_line_profiler.lib /pdb:line_profiler\_line_profiler.pdb /dll /version:0.0 /machine:X86 /INCREMENTAL:NO /EXPORT:PyInit__line_profiler C:\Users\user\Anaconda3\libs\python38.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:line_profiler\_line_profiler.cp38-win_amd64.pyd.manifest" failed (exit code 1112) with the following output:
python38.lib(python38.dll) : fatal error LNK1112: Modul-Computertyp "x64" steht in Konflikt mit dem Zielcomputertyp "x86".
ninja: build stopped: subcommand failed.发布于 2020-10-08 13:39:46
问题是并非所有环境变量都被正确设置。为此,可以/需要执行文件C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvars64.bat。这几乎是在Develper命令提示符的启动时完成的,这解释了为什么在此控制台中工作时可以找到kernel32.lib。
第二个错误发生,因为Develper提示符没有执行脚本的x64版本,因此将变量设置到x86编译器的路径。使用"x64本机工具命令提示符for VS 2019“(可以在”开始“菜单中找到)解决了这个问题。
https://stackoverflow.com/questions/64249759
复制相似问题