Hi all,

I am trying to install detools package from pypi using "pip install detools"

In the process of installing, initially I got some error regarding the requirement of C++ Build tools as detools contains some c++ extensions need to be compiled. I have installed the build tools as per the documentation.

Now, iam getting the following error logs

  "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.37.32822\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -IC:\Users\Mahanksa\Anaconda3\include -IC:\Users\Mahanksa\Anaconda3\Include "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.37.32822\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\VS\include" /Tcdetools/libdivsufsort/divsufsort.c /Fobuild\temp.win-amd64-cpython-39\Release\detools/libdivsufsort/divsufsort.obj
      divsufsort.c
      detools/libdivsufsort/divsufsort.c(5): fatal error C1083: Cannot open include file: 'stdio.h': No such file or directory
      error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\VC\\Tools\\MSVC\\14.37.32822\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
      [end of output]
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for detools
  Running setup.py clean for detools
Failed to build detools
ERROR: Could not build wheels for detools, which is required to install pyproject.toml-based projects

Any help is highly appreciated

Hello @Mahankali, Sai Charan,

Welcome to Microsoft Q&A forum.

Perhaps some files/components are missing, not sure what you have installed especially for some C++ tools/extensions… did you try to install the Windows SDK(normally from VS Installer > Modify > Individual components > Windows 10/11 SDK)?

Could you please share us the documentation that you referred to? And if possible, it will be helpful for us to check further if you can share us the steps to reproduce this error.

Hi @Tianyu Sun-MSFT ,

Below are the steps I followed, FYI currently my system is running on windows 10

  • Installed Microsoft visual studio Installer
  • Selected Desktop Development with C++ (below screenshot 1)
  • Selected the Optional tools (below screenshot 2)
  • Selected the Individual Components (which are default) (below screenshot 3)
  • Downloaded and Installed the packages
  • Tried to install the 'detools' python package using the command pip install detool
  • Got the below error logs

    Collecting detools
      Using cached detools-0.53.0.tar.gz (11.1 MB)
      Preparing metadata (setup.py) ... done
    Requirement already satisfied: humanfriendly in c:\users\mahanksa\anaconda3\lib\site-packages (from detools) (10.0)
    Requirement already satisfied: bitstruct in c:\users\mahanksa\anaconda3\lib\site-packages (from detools) (8.17.0)
    Requirement already satisfied: pyelftools in c:\users\mahanksa\anaconda3\lib\site-packages (from detools) (0.29)
    Requirement already satisfied: zstandard in c:\users\mahanksa\anaconda3\lib\site-packages (from detools) (0.18.0)
    Requirement already satisfied: lz4 in c:\users\mahanksa\anaconda3\lib\site-packages (from detools) (4.3.2)
    Requirement already satisfied: heatshrink2 in c:\users\mahanksa\anaconda3\lib\site-packages (from detools) (0.12.0)
    Requirement already satisfied: pyreadline3 in c:\users\mahanksa\anaconda3\lib\site-packages (from humanfriendly->detools) (3.4.1)
    Building wheels for collected packages: detools
      Building wheel for detools (setup.py) ... error
      error: subprocess-exited-with-error
      × python setup.py bdist_wheel did not run successfully.
      │ exit code: 1
      ╰─> [39 lines of output]
          running bdist_wheel
          running build
          running build_py
          creating build
          creating build\lib.win-amd64-cpython-39
          creating build\lib.win-amd64-cpython-39\detools
          copying detools\apply.py -> build\lib.win-amd64-cpython-39\detools
          copying detools\common.py -> build\lib.win-amd64-cpython-39\detools
          copying detools\create.py -> build\lib.win-amd64-cpython-39\detools
          copying detools\errors.py -> build\lib.win-amd64-cpython-39\detools
          copying detools\info.py -> build\lib.win-amd64-cpython-39\detools
          copying detools\version.py -> build\lib.win-amd64-cpython-39\detools
          copying detools\__init__.py -> build\lib.win-amd64-cpython-39\detools
          copying detools\__main__.py -> build\lib.win-amd64-cpython-39\detools
          creating build\lib.win-amd64-cpython-39\detools\compression
          copying detools\compression\crle.py -> build\lib.win-amd64-cpython-39\detools\compression
          copying detools\compression\heatshrink.py -> build\lib.win-amd64-cpython-39\detools\compression
          copying detools\compression\lz4.py -> build\lib.win-amd64-cpython-39\detools\compression
          copying detools\compression\none.py -> build\lib.win-amd64-cpython-39\detools\compression
          copying detools\compression\__init__.py -> build\lib.win-amd64-cpython-39\detools\compression
          copying detools\data_format\aarch64.py -> build\lib.win-amd64-cpython-39\detools\data_format
          copying detools\data_format\arm_cortex_m4.py -> build\lib.win-amd64-cpython-39\detools\data_format
          copying detools\data_format\elf.py -> build\lib.win-amd64-cpython-39\detools\data_format
          copying detools\data_format\utils.py -> build\lib.win-amd64-cpython-39\detools\data_format
          copying detools\data_format\xtensa_lx106.py -> build\lib.win-amd64-cpython-39\detools\data_format
          copying detools\data_format\__init__.py -> build\lib.win-amd64-cpython-39\detools\data_format
          running build_ext
          building 'detools.suffix_array' extension
          creating build\temp.win-amd64-cpython-39
          creating build\temp.win-amd64-cpython-39\Release
          creating build\temp.win-amd64-cpython-39\Release\detools
          creating build\temp.win-amd64-cpython-39\Release\detools\libdivsufsort
          creating build\temp.win-amd64-cpython-39\Release\detools\sais
     "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -IC:\Users\Mahanksa\Anaconda3\include -IC:\Users\Mahanksa\Anaconda3\Include "-IC:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\include" "-IC:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\ATLMFC\include" "-IC:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\VS\include" /Tcdetools/libdivsufsort/divsufsort.c /Fobuild\temp.win-amd64-cpython-39\Release\detools/libdivsufsort/divsufsort.obj      
     divsufsort.c       
    detools/libdivsufsort/divsufsort.c(5): fatal error C1083: Cannot open include file: 'stdio.h': No such file or directory       
    error: command 'C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.37.32822\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2       [end of output]    
    note: This error originates from a subprocess, and is likely not a problem with pip.   
    ERROR: Failed building wheel for detools   Running setup.py clean for detools Failed to build detools ERROR: Could not build wheels for detools, which is required to install pyproject.toml-based projects
    											

    Hi @Mahankali, Sai Charan,

    Looks like the stdio.h file is not included in the correct directory, or the file doesn’t exist. I tested on a new clean Win 10 machine and followed your steps. The detool package was installed successfully, so I believe the file also exists on your side.

    I agree with RLWA32 and probably, if you try to use the command prompt provided by VS(Developer Command Prompt for VS 2022), it may detect the file and install the detool package, please have a try and let us know the result.

    Hi @RLWA32 & @Tianyu Sun-MSFT thanks for your thoughts, I have tried to execute the installation command in VS developer command prompt and x64 Native tools command prompts, and there is no change in error.

    I have tried manually adding the stdio.h file path in env variables (INCLUDE) and I got other file not available error "Cannot open include file: 'basetsd.h': No such file or directory"and i resolved it too by adding it's path manually to env variables. Now iam getting LINK : fatal error LNK1104: cannot open file 'kernel32.lib'.

    Hi @Tianyu Sun-MSFT I have tried almost everything available on the internet. Uninstalled and reinstalled the vs build tools multiple times. I did not found any documentation on configuring the environment variables which will help in finding the required PATH. Just want to know if I am missing anything

    Thank You

    Just want to know if I am missing anything

    No, the workload and the components that you selected to install are enough.

    Does installing the latest version of Windows SDK component from VS Installer work?

    BTW, the Python I downloaded is version 3.11.x. I’m not 100% sure if different versions of Python will/will not cause this issue.

    The command prompt shortcuts that are created by the Visual Studio Installer properly configure environment variables for running the command line tools. These variables set paths for C/C++ include files and paths to be searched for libraries.

    I also have the 10.0.20348.0 version of the Windows SDK installed and the "stdio.h" file is provided by the Windows SDK. As a component of the UCRT, it is located at "C:\Program Files (x86)\Windows Kits\10\Include\10.0.20348.0\ucrt\stdio.h".

    So it seems to me that you are probably not using a VS provided command line environment and the CL.exe command line does not provide the path needed for files from the Windows SDK as shown above. At a minimum the CL.exe command line needs /I "C:\Program Files (x86)\Windows Kits\10\Include\10.0.20348.0\ucrt"

    Hi @RLWA32 ,

    From your information, I understood that cli.exe is not having the knowledge of location of required files.

    Can you guide me on how to resolve this issue as I am new to this tool and environment.

    Thank you

    @Mahankali, Sai Charan, I suggest that you use one of the command prompts that should have been part of your VS2022 installation. You can read more about them at Use the Microsoft C++ toolset from the command line. Pay particular attention to the section at Developer command prompt shortcuts. I am not familiar with the tools that you are using so I cannot guide you as to which of the available choices best fits your needs. You should select one based on what you are trying to accomplish such as building for 32-bits or 64-bits.

    The available choices should look like this in the Windows Start menu. The image below is an example of the expanded content of the Visual Studio 2022 folder in the menu -