Home > Back-end >  pip install pythonnet errored out with exit status 1 on Windows 10 (Python 3.10.1)
pip install pythonnet errored out with exit status 1 on Windows 10 (Python 3.10.1)

Time:01-02

According to the official Python.NET documention I'm supposed to install it using pip install pythonnet, this gives me an error however. I have upgraded the following packages trying to fix it:

  • pip
  • setuptools
  • wheel

This however didn't fix it and it's throwing some errors.

Collecting pythonnet
  Using cached pythonnet-2.5.2.tar.gz (1.9 MB)
  Preparing metadata (setup.py) ... done
Requirement already satisfied: pycparser in c:\users\kiron\appdata\local\programs\python\python310\lib\site-packages (from pythonnet) (2.21)
Building wheels for collected packages: pythonnet
  Building wheel for pythonnet (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: 'c:\users\kiron\appdata\local\programs\python\python310\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\kiron\\AppData\\Local\\Temp\\pip-install-aqpb12ju\\pythonnet_af0b8f5732a345fbb5e2d512446e9f59\\setup.py'"'"'; __file__='"'"'C:\\Users\\kiron\\AppData\\Local\\Temp\\pip-install-aqpb12ju\\pythonnet_af0b8f5732a345fbb5e2d512446e9f59\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\kiron\AppData\Local\Temp\pip-wheel-teu689ee'
       cwd: C:\Users\kiron\AppData\Local\Temp\pip-install-aqpb12ju\pythonnet_af0b8f5732a345fbb5e2d512446e9f59\
  Complete output (91 lines):
  running bdist_wheel
  running build
  running build_ext
  Checking for updates from https://www.nuget.org/api/v2/.
  Currently running NuGet.exe 4.1.0.
  Updating NuGet.exe to 6.0.0.
  Update successful.
  Cannot find the specified version of msbuild: '14'
  MSBuild auto-detection: using msbuild version '16.11.2.50704' from 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\bin'.
  Restoring NuGet package NUnit.ConsoleRunner.3.11.1.
  Restoring NuGet package NUnit.3.12.0.
  Adding package 'NUnit.3.12.0' to folder 'C:\Users\kiron\AppData\Local\Temp\pip-install-aqpb12ju\pythonnet_af0b8f5732a345fbb5e2d512446e9f59\packages'
  Adding package 'NUnit.ConsoleRunner.3.11.1' to folder 'C:\Users\kiron\AppData\Local\Temp\pip-install-aqpb12ju\pythonnet_af0b8f5732a345fbb5e2d512446e9f59\packages'
  Added package 'NUnit.ConsoleRunner.3.11.1' to folder 'C:\Users\kiron\AppData\Local\Temp\pip-install-aqpb12ju\pythonnet_af0b8f5732a345fbb5e2d512446e9f59\packages'
  Restoring NuGet package System.ValueTuple.4.5.0.
  Adding package 'System.ValueTuple.4.5.0' to folder 'C:\Users\kiron\AppData\Local\Temp\pip-install-aqpb12ju\pythonnet_af0b8f5732a345fbb5e2d512446e9f59\packages'
  Added package 'NUnit.3.12.0' to folder 'C:\Users\kiron\AppData\Local\Temp\pip-install-aqpb12ju\pythonnet_af0b8f5732a345fbb5e2d512446e9f59\packages'
  Restoring NuGet package UnmanagedExports.1.2.7.
  Adding package 'UnmanagedExports.1.2.7' to folder 'C:\Users\kiron\AppData\Local\Temp\pip-install-aqpb12ju\pythonnet_af0b8f5732a345fbb5e2d512446e9f59\packages'
  Added package 'System.ValueTuple.4.5.0' to folder 'C:\Users\kiron\AppData\Local\Temp\pip-install-aqpb12ju\pythonnet_af0b8f5732a345fbb5e2d512446e9f59\packages'
  Added package 'UnmanagedExports.1.2.7' to folder 'C:\Users\kiron\AppData\Local\Temp\pip-install-aqpb12ju\pythonnet_af0b8f5732a345fbb5e2d512446e9f59\packages'

  NuGet Config files used:
      C:\Users\kiron\AppData\Roaming\NuGet\NuGet.Config
      C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config

  Feeds used:
      C:\Users\kiron\.nuget\packages\
      https://api.nuget.org/v3/index.json
      https://packages.stride3d.net/nuget
      C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\

  Installed:
      4 package(s) to packages.config projects
  Traceback (most recent call last):
    File "C:\Users\kiron\AppData\Local\Temp\pip-install-aqpb12ju\pythonnet_af0b8f5732a345fbb5e2d512446e9f59\tools\geninterop\geninterop.py", line 396, in <module>
      sys.exit(main())
    File "C:\Users\kiron\AppData\Local\Temp\pip-install-aqpb12ju\pythonnet_af0b8f5732a345fbb5e2d512446e9f59\tools\geninterop\geninterop.py", line 357, in main
      python_h = preprocess_python_headers()
    File "C:\Users\kiron\AppData\Local\Temp\pip-install-aqpb12ju\pythonnet_af0b8f5732a345fbb5e2d512446e9f59\tools\geninterop\geninterop.py", line 238, in preprocess_python_headers
      for line in _check_output(cmd).splitlines():
    File "C:\Users\kiron\AppData\Local\Temp\pip-install-aqpb12ju\pythonnet_af0b8f5732a345fbb5e2d512446e9f59\tools\geninterop\geninterop.py", line 46, in _check_output
      output = subprocess.check_output(*args, **kwargs)
    File "c:\users\kiron\appdata\local\programs\python\python310\lib\subprocess.py", line 420, in check_output
      return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
    File "c:\users\kiron\appdata\local\programs\python\python310\lib\subprocess.py", line 501, in run
      with Popen(*popenargs, **kwargs) as process:
    File "c:\users\kiron\appdata\local\programs\python\python310\lib\subprocess.py", line 966, in __init__
      self._execute_child(args, executable, preexec_fn, close_fds,
    File "c:\users\kiron\appdata\local\programs\python\python310\lib\subprocess.py", line 1435, in _execute_child
      hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
  FileNotFoundError: [WinError 2] The system cannot find the file specified
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "C:\Users\kiron\AppData\Local\Temp\pip-install-aqpb12ju\pythonnet_af0b8f5732a345fbb5e2d512446e9f59\setup.py", line 630, in <module>
      setup(
    File "c:\users\kiron\appdata\local\programs\python\python310\lib\site-packages\setuptools\__init__.py", line 155, in setup
      return distutils.core.setup(**attrs)
    File "c:\users\kiron\appdata\local\programs\python\python310\lib\site-packages\setuptools\_distutils\core.py", line 148, in setup
      return run_commands(dist)
    File "c:\users\kiron\appdata\local\programs\python\python310\lib\site-packages\setuptools\_distutils\core.py", line 163, in run_commands
      dist.run_commands()
    File "c:\users\kiron\appdata\local\programs\python\python310\lib\site-packages\setuptools\_distutils\dist.py", line 967, in run_commands
      self.run_command(cmd)
    File "c:\users\kiron\appdata\local\programs\python\python310\lib\site-packages\setuptools\_distutils\dist.py", line 986, in run_command
      cmd_obj.run()
    File "C:\Users\kiron\AppData\Local\Temp\pip-install-aqpb12ju\pythonnet_af0b8f5732a345fbb5e2d512446e9f59\setup.py", line 612, in run
      return bdist_wheel.bdist_wheel.run(self)
    File "c:\users\kiron\appdata\local\programs\python\python310\lib\site-packages\wheel\bdist_wheel.py", line 299, in run
      self.run_command('build')
    File "c:\users\kiron\appdata\local\programs\python\python310\lib\site-packages\setuptools\_distutils\cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "c:\users\kiron\appdata\local\programs\python\python310\lib\site-packages\setuptools\_distutils\dist.py", line 986, in run_command
      cmd_obj.run()
    File "c:\users\kiron\appdata\local\programs\python\python310\lib\site-packages\setuptools\_distutils\command\build.py", line 135, in run
      self.run_command(cmd_name)
    File "c:\users\kiron\appdata\local\programs\python\python310\lib\site-packages\setuptools\_distutils\cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "c:\users\kiron\appdata\local\programs\python\python310\lib\site-packages\setuptools\_distutils\dist.py", line 986, in run_command
      cmd_obj.run()
    File "c:\users\kiron\appdata\local\programs\python\python310\lib\site-packages\setuptools\_distutils\command\build_ext.py", line 339, in run
      self.build_extensions()
    File "c:\users\kiron\appdata\local\programs\python\python310\lib\site-packages\setuptools\_distutils\command\build_ext.py", line 448, in build_extensions
      self._build_extensions_serial()
    File "c:\users\kiron\appdata\local\programs\python\python310\lib\site-packages\setuptools\_distutils\command\build_ext.py", line 473, in _build_extensions_serial
      self.build_extension(ext)
    File "C:\Users\kiron\AppData\Local\Temp\pip-install-aqpb12ju\pythonnet_af0b8f5732a345fbb5e2d512446e9f59\setup.py", line 302, in build_extension
      subprocess.check_call([sys.executable, geninterop, interop_file])
    File "c:\users\kiron\appdata\local\programs\python\python310\lib\subprocess.py", line 369, in check_call
      raise CalledProcessError(retcode, cmd)
  subprocess.CalledProcessError: Command '['c:\\users\\kiron\\appdata\\local\\programs\\python\\python310\\python.exe', 'tools\\geninterop\\geninterop.py', 'src\\runtime\\interop310.cs']' returned non-zero exit status 1.
  ----------------------------------------
  ERROR: Failed building wheel for pythonnet
  Running setup.py clean for pythonnet
Failed to build pythonnet
Installing collected packages: pythonnet
    Running setup.py install for pythonnet ... error
    ERROR: Command errored out with exit status 1:
     command: 'c:\users\kiron\appdata\local\programs\python\python310\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\kiron\\AppData\\Local\\Temp\\pip-install-aqpb12ju\\pythonnet_af0b8f5732a345fbb5e2d512446e9f59\\setup.py'"'"'; __file__='"'"'C:\\Users\\kiron\\AppData\\Local\\Temp\\pip-install-aqpb12ju\\pythonnet_af0b8f5732a345fbb5e2d512446e9f59\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\kiron\AppData\Local\Temp\pip-record-xe4ba95q\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\kiron\appdata\local\programs\python\python310\Include\pythonnet'
         cwd: C:\Users\kiron\AppData\Local\Temp\pip-install-aqpb12ju\pythonnet_af0b8f5732a345fbb5e2d512446e9f59\
    Complete output (6 lines):
    usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
       or: setup.py --help [cmd1 cmd2 ...]
       or: setup.py --help-commands
       or: setup.py cmd --help

    error: option --single-version-externally-managed not recognized
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\users\kiron\appdata\local\programs\python\python310\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\kiron\\AppData\\Local\\Temp\\pip-install-aqpb12ju\\pythonnet_af0b8f5732a345fbb5e2d512446e9f59\\setup.py'"'"'; __file__='"'"'C:\\Users\\kiron\\AppData\\Local\\Temp\\pip-install-aqpb12ju\\pythonnet_af0b8f5732a345fbb5e2d512446e9f59\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\kiron\AppData\Local\Temp\pip-record-xe4ba95q\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\kiron\appdata\local\programs\python\python310\Include\pythonnet' Check the logs for full command output.

Now, I do see that it has something to do with my VS2019 installation, but I cannot tell what the issue is. Should I perhaps do a fresh reinstall of VS2019? And if so, what workloads and individual components should I install?

EDIT 1

I have just done a fresh reinstall of VS2019, with the following workloads, their installation detailsand the following individual components: installed workloads part 1 installed workloads part 2

individual components .NET individual components Cloud, database and server individual components Code tools individual components Compilers, build tools and runtimes part 1 individual components Compilers, build tools and runtimes part 2 individual components Compilers, build tools and runtimes part 2 individual components Debugging and testing and Development activities individual components Games and Graphics and SDKs, libraries and frameworks part 1 individual components SDKs, libraries and frameworks part 2

I'm still getting the same error in pip.

CodePudding user response:

Python.NET 2.5.2 only supports Python 3.8 or earlier. You might want to try 3.0.0 preview if you need it to run with 3.10.

  • Related