在Windows x64中运行Cython-致命错误C1083:无法打开包含文件:'basetsd.h':没有这样的文件或目录 [英] Running Cython in Windows x64 - fatal error C1083: Cannot open include file: 'basetsd.h': No such file or directory
问题描述
我一直在尝试在Windows 7系统上安装适用于Python 2.7的Cython.特别是,我更喜欢64位中的所有内容. (以防万一,我需要Cython,因为Cython是我需要另一个用于某些专业数值分析的软件包的组件之一.而x64可能是存储大型数据集的优势.)
I have been trying to install Cython for Python 2.7 on my Window 7 system. In particular, I prefer everything in 64 bits. (In case you wonder, I need Cython because Cython is one of the components I need for another package for some specialized numerical analysis. And x64 is potentially an advantage for storage of large data sets.)
因此,我从官方网站下载了x64 Python 2.7.从 Christoph Gohlke 中获得了Cython.当然,适用于Python 2.7的amd64版本.在安装之前,我使用此处(我认为它不起作用)和此处(但是这个应该).此时,我在C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin
目录中具有所有vcvars32.bat
,vcvars64.bat
,vcvars86_amd64.bat
,vcvarsx86_ia64.bat
.我运行了vcvars64.bat
,没有错误消息.
So I downloaded the x64 Python 2.7 from the official website. Got Cython from Christoph Gohlke. The amd64 version for Python 2.7 of course. Before I installed, I added Python 2.7 into the registry with the .reg
file found in Joe DF's answer here. Afterwards, I installed the Visual C++ compiler from here (I don't think it works) and here (but this one should). At this point, I have in my C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin
directory all of vcvars32.bat
, vcvars64.bat
, vcvars86_amd64.bat
, vcvarsx86_ia64.bat
. I ran vcvars64.bat
and there was no error message.
随后,我遵循了此页面,以创建"hello world"测试文件.
Subsequently, I followed this page to create a "hello world" test file.
然后,我得到了这个错误.
Then, I got this error.
...\Tests>python setup.py build_ext --inplace
running build_ext
building 'hello' extension
error: Unable to find vcvarsall.bat
所以我心想:Cython找不到该文件,因为它不存在. (我在整个硬盘驱动器中搜索了它.)因此,我将vcvars64.bat
从...\VC\bin
复制到了\VC
,并将名称更改为vcvarsall.bat
.现在vcvarsall错误消失了.而且……自然会出现新的错误.
So I thought to myself: Well, Cython can't find that file because it does not exist. (I searched my whole harddrive for it.) So I copied vcvars64.bat
from ...\VC\bin
to \VC
and changed the name to vcvarsall.bat
. Now vcvarsall error is gone. And ... naturally, a new error emerges.
...\Tests>python setup.py build_ext --inplace
running build_ext
building 'hello' extension
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\amd64\cl.exe /c /nolog
o /Ox /MD /W3 /GS- /DNDEBUG -IC:\Python27\include -IC:\Python27\PC /Tchello.c /F
obuild\temp.win-amd64-2.7\Release\hello.obj
hello.c
C:\Python27\include\pyconfig.h(227) : fatal error C1083: Cannot open include fil
e: 'basetsd.h': No such file or directory
error: command '"C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\amd64
\cl.exe"' failed with exit status 2
现在我不知道如何进行.我该怎么办?非常感谢您的帮助.
Now I have no idea how to proceed. What should I do? Your help is much appreciated.
(为清楚起见,我确实尝试将编译器设置为Mingw32.但是还有其他错误.我专注于使VC暂时运行.)
(For clarity, I did try setting the compiler to Mingw32. But there are other errors. I am focusing on getting VC to work for now.)
我尝试按照此页面上的说明使用SDK构建环境CMD 一个>.我收到了同样的错误.
I tried using the SDK build environment CMD following the instructions on this page. I received the same error.
推荐答案
如果当前(2017年)使用Visual C ++ 2015工具遇到相同错误,请再次启动安装程序,并根据您的操作系统选择Windows 8.1/10 SDK.这将修复basestd.h
错误.
In case anyone is currently (2017) facing same error with visual C++ 2015 tools, launch setup again and also select windows 8.1 / 10 SDK depending upon your OS. This will fix basestd.h
error.
如果仍然无法正常运行,请尝试从以下位置启动生成工具:C:\ Program Files(x86)\ Microsoft Visual C ++生成工具.
If it is still not working, try launching build tools from: C:\Program Files (x86)\Microsoft Visual C++ Build Tools.
另一种选择是,只需安装anaconda 2或3(如果您也不想出现内存错误,则安装64位).它包含所有预先构建的重要软件包:sklearn,matplotlib,scipy,numpy,pandas甚至是Web开发框架(例如flask).
Another alternative would be, just install anaconda 2 or 3 (64 bit if also you don't want memory errors). It contains all the important packages prebuilt: sklearn, matplotlib, scipy, numpy, pandas and even web development frameworks such as flask.
这篇关于在Windows x64中运行Cython-致命错误C1083:无法打开包含文件:'basetsd.h':没有这样的文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!