【问题标题】:error: command 'cl.exe' failed: No such file or directory Python 3.4错误:命令“cl.exe”失败:没有这样的文件或目录 Python 3.4
【发布时间】:2015-12-20 19:33:55
【问题描述】:

我一直在尝试通过运行 python setup.py install 来安装 pyodbc 3.0.7,但仍然遇到问题。目前我遇到了“错误:命令'cl.exe'失败:没有这样的文件或目录”墙。我在网上寻找的时间比我想承认的要弄清楚发生了什么的时间要长。

我使用的是 64 位版本的 Python 3.4

我有 Microsoft Visual Studio 10.0。

我已确认 vcvarsall.bat 位于 Program Files (x86)\Microsoft Visual Studio 10.0\VC 中。

我运行的是 64 位,所以我添加了 amd64 文件夹并将 vcvars64.bat 放在 Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64 中

我确认 cl.exe 位于 Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin

我已经重新启动了我的计算机,以确保这不是问题所在。

但是当我尝试安装 pyodbc 时,我得到以下信息

C:\Users\William\Downloads\pyodbc-3.0.7\pyodbc-3.0.7>python setup.py install
running install
running bdist_egg
running egg_info
writing pyodbc.egg-info\PKG-INFO
writing top-level names to pyodbc.egg-info\top_level.txt
writing dependency_links to pyodbc.egg-info\dependency_links.txt
reading manifest file 'pyodbc.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching 'tests\*'
writing manifest file 'pyodbc.egg-info\SOURCES.txt'
installing library code to build\bdist.win-amd64\egg
running install_lib
running build_ext
building 'pyodbc' extension
creating build
creating build\temp.win-amd64-3.4
creating build\temp.win-amd64-3.4\Release
creating build\temp.win-amd64-3.4\Release\Users
creating build\temp.win-amd64-3.4\Release\Users\William
creating build\temp.win-amd64-3.4\Release\Users\William\Downloads
creating build\temp.win-amd64-3.4\Release\Users\William\Downloads\pyodbc-3.0.7
creating build\temp.win-amd64-3.4\Release\Users\William\Downloads\pyodbc-3.0.7\pyodbc-3.0.7
creating build\temp.win-amd64-3.4\Release\Users\William\Downloads\pyodbc-3.0.7\pyodbc-3.0.7\src
cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -DPYODBC_VERSION=3.0.7 -IC:\Python34\include -IC:\Python34\include /TpC:\Users\William\Downloads\pyodbc-3.0.7\pyodbc-3.0.7\src\buffer.cpp /Fobuild\temp.win-amd64-3.4\Release\Users\William\Downloads\pyodbc-3.0.7\pyodbc-3.0.7\src\buffer.obj /Wall /wd4668 /wd4820 /wd4711 /wd4100 /wd4127 /wd4191
error: command 'cl.exe' failed: No such file or directory

从那里,作为最后的努力,我尝试清理和构建,但遇到了同样的问题。

C:\Users\William\Downloads\pyodbc-3.0.7\pyodbc-3.0.7>py -3 setup.py clean --all build_ext --force
running clean
removing 'build\temp.win-amd64-3.4' (and everything under it)
'build\lib.win-amd64-3.4' does not exist -- can't clean it
'build\bdist.win-amd64' does not exist -- can't clean it
'build\scripts-3.4' does not exist -- can't clean it
removing 'build'
running build_ext
building 'pyodbc' extension
creating build
creating build\temp.win-amd64-3.4
creating build\temp.win-amd64-3.4\Release
creating build\temp.win-amd64-3.4\Release\Users
creating build\temp.win-amd64-3.4\Release\Users\William
creating build\temp.win-amd64-3.4\Release\Users\William\Downloads
creating build\temp.win-amd64-3.4\Release\Users\William\Downloads\pyodbc-3.0.7
creating build\temp.win-amd64-3.4\Release\Users\William\Downloads\pyodbc-3.0.7\pyodbc-3.0.7
creating build\temp.win-amd64-3.4\Release\Users\William\Downloads\pyodbc-3.0.7\pyodbc-3.0.7\src
cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -DPYODBC_VERSION=3.0.7 -IC:\Python34\include -IC:\Python34\include /TpC:\Users\William\Downloads\pyodbc-3.0.7\pyodbc-3.0.7\src\buffer.cpp /Fobuild\temp.win-amd64-3.4\Release\Users\William\Downloads\pyodbc-3.0.7\pyodbc-3.0.7\src\buffer.obj /Wall /wd4668 /wd4820 /wd4711 /wd4100 /wd4127 /wd4191
error: command 'cl.exe' failed: No such file or directory

我一直使用 pip,所以这不是我熟悉的东西,所以也许我做错了什么。任何帮助,我将永远感激不尽,因为我认为此时我已经用尽了所有资源。 (或者 pyodbc 3.0.7 的预构建副本也可以工作!)

【问题讨论】:

  • 我刚刚删除了 Python 标签。原因很简单,Python 只是尝试调用 cl.exe(这是 Microsoft 编译器),但无论是谁调用它,它都不应该工作。所以,基本上,你的问题归结为你不能在命令行上运行cl.exe

标签: visual-studio-2010 cl


【解决方案1】:

您可能尝试从默认的Command Prompt 构建。这不起作用。

您必须准备一个Command Prompt。我使用以下命令来获取具有正确设置的命令行:

C:\Windows\System32\cmd.exe /E:ON /V:ON /T:0E /K "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /RELEASE /x64

您可以在桌面上创建一个新的快捷方式,这样您在安装新的 python 模块时就不必键入它。

现在您可以运行一个新的Command Prompt 并构建一个Python 包。

【讨论】:

  • 你的方法是正确的。但是,我相信通过简单地运行 VS 从同一命令提示符提供的批处理脚本就可以实现正确的设置。该脚本正是问题中提到的vcvarsall.bat
【解决方案2】:

Python 3.4 需要 Visual Studio 2010 来编译像 pyodbc 这样的包,所以如果你安装了不同的版本,那肯定是问题所在。只需重新安装 Visual Studio,一切正常! https://www.microsoft.com/en-us/download/details.aspx?id=23691 如果您仍然有问题,请考虑更换为即将推出的 3.5 或 3.6!

希望对你有所帮助, 邮票

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-01
    • 2020-04-01
    • 2013-07-13
    • 1970-01-01
    • 2016-07-05
    • 2013-02-04
    相关资源
    最近更新 更多