点安装 cx_freeze:"command 'cl.exe' failed: No such file or directory"

pip install cx_freeze: "command 'cl.exe' failed: No such file or directory"

我在 Windows 7,我安装了 Python 3.5.1。

我想从 Python 脚本创建可执行文件。

到目前为止我做了什么:

我 运行 pip install cx_freeze 我得到了 Unable to find vcvarsall.bat 错误。

@Cody Piersall 链接到 Steve Dowers blog entry

我从那里下载并安装了 Visual C++ Build Tools 2015。

现在我安装了这些 *Microsoft Visual C++ **:Screenshot

而且我在 C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\:

中安装了 vcvars* 批次

我漂亮的 PATH 是:

C:\run\Python_3_5\Scripts\;
C:\run\Python_3_5\;
C:\Windows\system32;
C:\Windows;
C:\Windows\System32\Wbem;
C:\Windows\System32\WindowsPowerShell\v1.0\;
C:\ProgramData\Oracle\Java\javapath;
C:\Program Files (x86)\Intel\OpenCL SDK.0\bin\x86;
C:\Program Files (x86)\Intel\OpenCL SDK.0\bin\x64;
C:\run\Haskell-Platform\lib\extralibs\bin;
C:\run\Haskell-Platform\bin;
C:\Users\Nils-Hero\AppData\Roaming\cabal\bin;
C:\run\Haskell-Platform\mingw\bin;
C:\Program Files (x86)\Windows Kits\Windows Performance Toolkit\;
C:\Program Files (x86)\Intel\OpenCL SDK.0\bin\x64;

问题:

当我现在重新运行 pip install cx_freeze 时,它没有找到文件 cl.exe:

Collecting cx_freeze
  Using cached cx_Freeze-4.3.4.tar.gz
Installing collected packages: cx-freeze
  Running setup.py install for cx-freeze ... error
    Complete output from command c:\run\python_3_5\python.exe -u -c "import setuptools, tokenize;__file__='C:\Users\NILS-H~1\AppData\Local\Temp\pip-build-9lhua9e9\cx-freeze\setup.py'
;exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record C:\Users\NILS-H~1\AppData\Local\Temp\pip-bb2i8jxv-record\install-re
cord.txt --single-version-externally-managed --compile:
    adding base module named _bootlocale
    adding base module named _collections_abc
    adding base module named _compression
    ...
    ... adding a lot more base modules  ...
    ...
    running install
    running build
    running build_py
    creating build\lib.win-amd64-3.5
    creating build\lib.win-amd64-3.5\cx_Freeze
    copying cx_Freeze\common.py -> build\lib.win-amd64-3.5\cx_Freeze
    copying cx_Freeze\dist.py -> build\lib.win-amd64-3.5\cx_Freeze
    ...
    ... creating and copying a lot more things ...
    ...
    running build_ext
    building 'cx_Freeze.util' extension
    creating build\temp.win-amd64-3.5\Release
    creating build\temp.win-amd64-3.5\Release\source
    cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MT -Ic:\run\python_3_5\include -Ic:\run\python_3_5\include /Tcsource/util.c /Fobuild\temp.win-amd64-3.5\Release\source/util.obj
    error: command 'cl.exe' failed: No such file or directory

    ----------------------------------------
Command "c:\run\python_3_5\python.exe -u -c "import setuptools, tokenize;__file__='C:\Users\NILS-H~1\AppData\Local\Temp\pip-build-9lhua9e9\cx-freeze\setup.py';exec(compile(getattr(to
kenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record C:\Users\NILS-H~1\AppData\Local\Temp\pip-bb2i8jxv-record\install-record.txt --single-versio
n-externally-managed --compile" failed with error code 1 in C:\Users\NILS-H~1\AppData\Local\Temp\pip-build-9lhua9e9\cx-freeze\

此可执行文件在 C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\ 下,也在子文件夹中。

我猜 pip 找不到它是因为这些路径不在我的 PATH 上,但为什么 Visual C++ Build Tools 2015 安装程序不添加它们?我不敢手动调整一个 800MB 大小、持续 50 分钟的安装。所以我最好先在这里问一下。

好的。已解决。

我根据 this Question 的答案从一个轮子成功安装了 cx_freeze。

但是version 4.3.4 from the Gohlke site has a bug under Python 3.5 (ImportError: No module named '_frozen_importlib_external'). We have to wait until the cx_freeze author releases the next version of cx_freeze(好像很快)。

与此同时,Sebastian Krause 非常友好地从 repo cx_freeze 5.0 的最新代码中创建了一些轮子,并且这些轮子在我的测试中安装并且 运行 没有错误。