question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Pythonnet does not install on Python 3.10

See original GitHub issue

Environment

  • Pythonnet version: 2.5.2
  • Python version: 3.10
  • Operating System: Windows 10
  • .NET Runtime: 5.0.10

Details

    pip install pythonnet
  • If there was a crash, please include the traceback here.
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\hp\appdata\local\programs\python\python310\lib\site-packages (from pythonnet) (2.20)
Building wheels for collected packages: pythonnet
  Building wheel for pythonnet (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: 'C:\Users\hp\AppData\Local\Programs\Python\Python310\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\hp\\AppData\\Local\\Temp\\pip-install-1b930_7c\\pythonnet_09b2e5274ca748a4ba7d12bca0b70752\\setup.py'"'"'; __file__='"'"'C:\\Users\\hp\\AppData\\Local\\Temp\\pip-install-1b930_7c\\pythonnet_09b2e5274ca748a4ba7d12bca0b70752\\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\hp\AppData\Local\Temp\pip-wheel-bjzwvfmb'
       cwd: C:\Users\hp\AppData\Local\Temp\pip-install-1b930_7c\pythonnet_09b2e5274ca748a4ba7d12bca0b70752\
  Complete output (89 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 5.11.0.
  Update successful.
  Cannot find the specified version of msbuild: '14'
  MSBuild auto-detection: using msbuild version '17.0.0.48003' from 'C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\bin'.
  Restoring NuGet package System.ValueTuple.4.5.0.
  Restoring NuGet package NUnit.3.12.0.
  Restoring NuGet package UnmanagedExports.1.2.7.
  Restoring NuGet package NUnit.ConsoleRunner.3.11.1.
  Adding package 'NUnit.ConsoleRunner.3.11.1' to folder 'C:\Users\hp\AppData\Local\Temp\pip-install-1b930_7c\pythonnet_09b2e5274ca748a4ba7d12bca0b70752\packages'
  Adding package 'System.ValueTuple.4.5.0' to folder 'C:\Users\hp\AppData\Local\Temp\pip-install-1b930_7c\pythonnet_09b2e5274ca748a4ba7d12bca0b70752\packages'
  Adding package 'NUnit.3.12.0' to folder 'C:\Users\hp\AppData\Local\Temp\pip-install-1b930_7c\pythonnet_09b2e5274ca748a4ba7d12bca0b70752\packages'
  Adding package 'UnmanagedExports.1.2.7' to folder 'C:\Users\hp\AppData\Local\Temp\pip-install-1b930_7c\pythonnet_09b2e5274ca748a4ba7d12bca0b70752\packages'
  Added package 'UnmanagedExports.1.2.7' to folder 'C:\Users\hp\AppData\Local\Temp\pip-install-1b930_7c\pythonnet_09b2e5274ca748a4ba7d12bca0b70752\packages'
  Added package 'NUnit.ConsoleRunner.3.11.1' to folder 'C:\Users\hp\AppData\Local\Temp\pip-install-1b930_7c\pythonnet_09b2e5274ca748a4ba7d12bca0b70752\packages'
  Added package 'System.ValueTuple.4.5.0' to folder 'C:\Users\hp\AppData\Local\Temp\pip-install-1b930_7c\pythonnet_09b2e5274ca748a4ba7d12bca0b70752\packages'
  Added package 'NUnit.3.12.0' to folder 'C:\Users\hp\AppData\Local\Temp\pip-install-1b930_7c\pythonnet_09b2e5274ca748a4ba7d12bca0b70752\packages'

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

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

  Installed:
      4 package(s) to packages.config projects
  Traceback (most recent call last):
    File "C:\Users\hp\AppData\Local\Temp\pip-install-1b930_7c\pythonnet_09b2e5274ca748a4ba7d12bca0b70752\tools\geninterop\geninterop.py", line 396, in <module>
      sys.exit(main())
    File "C:\Users\hp\AppData\Local\Temp\pip-install-1b930_7c\pythonnet_09b2e5274ca748a4ba7d12bca0b70752\tools\geninterop\geninterop.py", line 357, in main
      python_h = preprocess_python_headers()
    File "C:\Users\hp\AppData\Local\Temp\pip-install-1b930_7c\pythonnet_09b2e5274ca748a4ba7d12bca0b70752\tools\geninterop\geninterop.py", line 238, in preprocess_python_headers
      for line in _check_output(cmd).splitlines():
    File "C:\Users\hp\AppData\Local\Temp\pip-install-1b930_7c\pythonnet_09b2e5274ca748a4ba7d12bca0b70752\tools\geninterop\geninterop.py", line 46, in _check_output
      output = subprocess.check_output(*args, **kwargs)
    File "C:\Users\hp\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\hp\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 501, in run
      with Popen(*popenargs, **kwargs) as process:
    File "C:\Users\hp\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 966, in __init__
      self._execute_child(args, executable, preexec_fn, close_fds,
    File "C:\Users\hp\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\hp\AppData\Local\Temp\pip-install-1b930_7c\pythonnet_09b2e5274ca748a4ba7d12bca0b70752\setup.py", line 630, in <module>
      setup(
    File "C:\Users\hp\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\__init__.py", line 153, in setup
      return distutils.core.setup(**attrs)
    File "C:\Users\hp\AppData\Local\Programs\Python\Python310\lib\distutils\core.py", line 148, in setup
      dist.run_commands()
    File "C:\Users\hp\AppData\Local\Programs\Python\Python310\lib\distutils\dist.py", line 966, in run_commands
      self.run_command(cmd)
    File "C:\Users\hp\AppData\Local\Programs\Python\Python310\lib\distutils\dist.py", line 985, in run_command
      cmd_obj.run()
    File "C:\Users\hp\AppData\Local\Temp\pip-install-1b930_7c\pythonnet_09b2e5274ca748a4ba7d12bca0b70752\setup.py", line 612, in run
      return bdist_wheel.bdist_wheel.run(self)
    File "C:\Users\hp\AppData\Local\Programs\Python\Python310\lib\site-packages\wheel\bdist_wheel.py", line 299, in run
      self.run_command('build')
    File "C:\Users\hp\AppData\Local\Programs\Python\Python310\lib\distutils\cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "C:\Users\hp\AppData\Local\Programs\Python\Python310\lib\distutils\dist.py", line 985, in run_command
      cmd_obj.run()
    File "C:\Users\hp\AppData\Local\Programs\Python\Python310\lib\distutils\command\build.py", line 135, in run
      self.run_command(cmd_name)
    File "C:\Users\hp\AppData\Local\Programs\Python\Python310\lib\distutils\cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "C:\Users\hp\AppData\Local\Programs\Python\Python310\lib\distutils\dist.py", line 985, in run_command
      cmd_obj.run()
    File "C:\Users\hp\AppData\Local\Programs\Python\Python310\lib\distutils\command\build_ext.py", line 340, in run
      self.build_extensions()
    File "C:\Users\hp\AppData\Local\Programs\Python\Python310\lib\distutils\command\build_ext.py", line 449, in build_extensions
      self._build_extensions_serial()
    File "C:\Users\hp\AppData\Local\Programs\Python\Python310\lib\distutils\command\build_ext.py", line 474, in _build_extensions_serial
      self.build_extension(ext)
    File "C:\Users\hp\AppData\Local\Temp\pip-install-1b930_7c\pythonnet_09b2e5274ca748a4ba7d12bca0b70752\setup.py", line 302, in build_extension
      subprocess.check_call([sys.executable, geninterop, interop_file])
    File "C:\Users\hp\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 369, in check_call
      raise CalledProcessError(retcode, cmd)
  subprocess.CalledProcessError: Command '['C:\\Users\\hp\\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\hp\AppData\Local\Programs\Python\Python310\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\hp\\AppData\\Local\\Temp\\pip-install-1b930_7c\\pythonnet_09b2e5274ca748a4ba7d12bca0b70752\\setup.py'"'"'; __file__='"'"'C:\\Users\\hp\\AppData\\Local\\Temp\\pip-install-1b930_7c\\pythonnet_09b2e5274ca748a4ba7d12bca0b70752\\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\hp\AppData\Local\Temp\pip-record-dw8k9clf\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\hp\AppData\Local\Programs\Python\Python310\Include\pythonnet'
         cwd: C:\Users\hp\AppData\Local\Temp\pip-install-1b930_7c\pythonnet_09b2e5274ca748a4ba7d12bca0b70752\
    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\hp\AppData\Local\Programs\Python\Python310\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\hp\\AppData\\Local\\Temp\\pip-install-1b930_7c\\pythonnet_09b2e5274ca748a4ba7d12bca0b70752\\setup.py'"'"'; __file__='"'"'C:\\Users\\hp\\AppData\\Local\\Temp\\pip-install-1b930_7c\\pythonnet_09b2e5274ca748a4ba7d12bca0b70752\\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\hp\AppData\Local\Temp\pip-record-dw8k9clf\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\hp\AppData\Local\Programs\Python\Python310\Include\pythonnet' Check the logs for full command output.

I am able to install Pythonnet on Python 3.9 but not on Python 3.10 I am aware that only Python 2.7 and 3.5-3.8 are tested but just bringing this issue to your knowledge.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

14reactions
suryapradhan123commented, Feb 22, 2022

Is there an official date for the release of a new version supporting Py3.10?

7reactions
filmorcommented, Feb 9, 2022

It has been merged into master. We will not backport support for 3.10 (or 3.9) back to the current stable version. You can install the prerelease using pip install --pre pythonnet.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to fix error during pythonnet installation
From the Python.NET docs I can see it doesn't support python 3.9 . You can download wheel file from here. As your python...
Read more >
pythonnet
Python.NET is a package that gives Python programmers nearly seamless integration with the ... Information on installation, FAQ, troubleshooting, debugging, ...
Read more >
PIP Install Pythonnet - A quick read
If you do not have a recent version of Python installed, you can install Python from ActiveState. You can check if pip is...
Read more >
Unresolved references with pythonnet
Hello! I am struggling in using the pythonnet package (3.0.1) with pycharm 2022.3.1 (Community Edition) and python 3.10.
Read more >
VeriStand Python API Fails to Install "Error: Option --Single ...
Issue Details. I am trying to install the VeriStand Python API while using Python 3.9 or 3.10. It seems like niveristand, pythonnet.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found