无法打开包含文件:'io.h':没有那个文件或目录。

107

我尝试使用Cython编译一个简单的.pyx文件。

print("hello")

这是我的setup.py文件:

from distutils.core import setup
from Cython.Build import cythonize

setup(
    ext_modules = cythonize("hello.pyx")
)

然后我运行了这个命令。

python setup.py build_ext --inplace
错误信息如下。我在谷歌上找了很久,但没有找到有用的信息。
    running build_ext
    building 'hello' extension
    C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD
-IC:\Users\Jackie\AppData\Local\Continuum\Anaconda3\include -IC:\Users\Jackie\AppData\Local\Continuum\Anaconda3\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE"
"-IC:\Program Files (x86)\Windows Kits\10\include\wdf\ucrt"
"-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\include\um"
"-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" /Tchello.c
/Fobuild\temp.win32-3.5\Release\hello.obj  
    hello.c
    c:\users\jackie\appdata\local\continuum\anaconda3\include\pyconfig.h(68):
fatal error C1083: Cannot open include file: 'io.h': No such file or
directory  
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\cl.exe' failed with exit status 2
请帮忙解决错误,谢谢。 我安装了Anaconda3 4.1.1、Python 3.5和Visual Studio Express 2015。

好的...在我卸载了所有与Microsoft和Python相关的软件并重新安装Anaconda和VS2015 Express之后,错误消失了。 然而,又出现了另一个错误... - user2869934
18个回答

2
如果安装构建工具没有解决问题,添加/编辑3个系统环境变量可能会有所帮助。
根据您安装的构建工具版本不同,您可能需要稍微修改路径。
安装Microsoft C++ Build Tools。我包括组件MSVC v143 - VS 2022 C++-x64/x86-BuildtoolsWindows 11 SDK (10.0.22000.0)。确切的版本可能不太重要。 添加系统环境变量INCLUDE,值为(根据您的版本进行调整)C:\Program Files (x86)\Windows Kits\10\Include\10.0.22000.0\ucrt;C:\Program Files (x86)\Windows Kits\10\Include\10.0.22000.0\shared。第一个目录应包含例如io.hcorecrt_wio.h,第二个目录应包含例如basetsd.h。 添加系统环境变量LIB,值为C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22000.0\um\x64;C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22000.0\ucrt\x64。 将C:\Program Files (x86)\Windows Kits\10\bin\10.0.22000.0\x86添加到系统环境变量Path中的值。该目录应包含rcdll.dllrc.exe。 重新启动系统。

正如Felipe Araya Olea所指出的那样,仅安装构建工具可能不足,因为在公司电脑上工作时访问注册表受到限制。然而,以上步骤解决了我的问题。


1
这是所有答案中唯一帮助了我的,谢谢谢谢谢谢!! - DanielY

1
在您的环境路径中添加Windows 10 SDK。

C:\Program Files (x86)\Windows Kits\10\Include\\ucrt

  1. 应用更改。
  2. 使用管理员权限打开新的命令提示符。
错误应该被移除。

1

当我尝试安装pyshark时,我遇到了相同的错误,我通过在VS 2017开发人员命令提示符中运行pip install pyshark并确保安装了VC++工具来解决此问题。


0
  1. 如果您的系统中安装了其他“Visual Studio Build Tools”,请先卸载它们。
  2. 重启您的系统。
  3. 从以下网址下载“Visual Studio 2019 Build Tools”并进行安装。 URL: https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2019 EXE: vs_buildtools__559949468.1570880854.exe
  4. 重启您的系统。
  5. 以管理员模式打开CMD,并尝试安装py包。对于我来说,在安装pyahocorasickpyodbc包时遇到了问题。
  6. 在安装上述工具后,请在添加/删除程序中检查。 控制面板中添加/删除程序的截图

0

请检查文件夹d:\New folder是否可访问,因为Windows 10 SDK和下载Visual Studio Build工具需要该文件夹用于临时文件。如果该文件夹不可用,则会出现以下问题描述的错误。


0

我试图在Windows 10上使用VS2017移植和构建pycocotools,但遇到了相同的错误:“未找到io.h”。

为了弄清楚为什么找不到“io.h”,终端输出可能会给出提示,即如何指定包含目录。 在我的情况下,使用了错误版本的Windows 10 SDK:

-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt

替代

-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt

没有 C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt(但有 C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0)。

最后,在控制面板中,我删除了 Windows Driver Kit 18362(该程序是通过 VS2019 安装的,但之后已将 VS2019 卸载,而这个 18362 还未完全卸载),并解决了 "io.h not found" 的问题。


让我更清楚地解释一下:

  • Windows SDK 10.0.17763.0 是通过 VS2017 引入的
  • Windows SDK 10.0.18362.0 是通过 VS2019 引入的 当存在多个版本的 Windows SDK(即使其目录不包含 ucrt 文件夹以包含文件),最新的版本将被选择,这会导致类似于 "io.h not found" 的错误。

-2

如果有任何安装Openstack或任何其他需要Python或Pip的应用程序(或netifaces,oslo.utils,python-cinderclient,msgpack,oslo.serialization,python-novaclient,PyYAML,pyperclip,colorama,pyreadline,attrs,wcwidth,cmd2,cliff,pycparser,cffi,cryptography,decorator,requestsexceptions,jsonpointer,jsonpatch,munch,jmespath,dogpile.cache,appdirs,OpenStack SDK,rfc3986,oslo.config,python-keystoneclient,osc-lib)的问题,并且还使用Visual Studio-请按照以下步骤操作:

  1. 安装Python 3.8.5
  2. Pip会随Python自动安装
  3. 重新启动系统(非常重要)
  4. 输入命令以安装任何应用程序:例如:pip install python-openstackclient

这对我有效,希望对其他人也有用。 - vasudha Anantharam

-2

我在尝试安装pyhook 1.5.1时遇到了一个非常烦人的错误。

  1. 我安装了Windows10 SDK(因为我使用的是Windows10)
  2. 以管理员模式运行Visual Studio x64命令提示符。
  3. 洗了个冷水澡。
  4. 最后按下回车键。

耶!它终于成功了。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接