Я попытался установить pytho nnet в коде с помощью ввода
pip install pythonnet
в терминале, и возникла ошибка.
Я также попытался git установить
pip install git+https://github.com/pythonnet/pythonnet -U --force
и cd
к директории и запустите python setup.py install
И я уверен, что мой setuptool и wheel обновлены
любой простой способ установить pythonnet
?
спасибо за помощь!
ошибка:
PS C:\Users\User\Desktop\Python> pip install pythonnet
Collecting pythonnet
Using cached pythonnet-2.4.0.tar.gz (1.8 MB)
Building wheels for collected packages: pythonnet
Building wheel for pythonnet (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: 'c:\users\user\appdata\local\programs\python\python38-32\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\user\\AppData\\Local\\Temp\\pip-install-35qtcmee\\pythonnet\\setup.py'"'"'; __file__='"'"'C:\\Users\\User\\AppData\\Local\\Temp\\pip-install-35qtcmee\\pythonnet\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\User\AppData\Local\Temp\pip-wheel-l_p_t2zy'
cwd: C:\Users\User\AppData\Local\Temp\pip-install-35qtcmee\pythonnet\
Complete output (76 lines):
running bdist_wheel
running build
running build_ext
?????? https://www.nuget.org/api/v2/ ????
?????? NuGet.exe 4.1.0?
???? NuGet.exe ? 5.4.0?
?????
Cannot find the specified version of msbuild: '14'
MSBuild auto-detection: using msbuild version '16.0.462.64354' from 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\bin'.
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\bin\Microsoft.CSharp.CurrentVersion.targets(321,5): error MSB4019: The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\bin\Roslyn\Microsoft.CSharp.Core.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on
disk. [C:\Users\User\AppData\Local\Temp\pip-install-35qtcmee\pythonnet\src\runtime\Python.Runtime.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\bin\Microsoft.CSharp.CurrentVersion.targets(321,5): error MSB4019: The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\bin\Roslyn\Microsoft.CSharp.Core.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on
disk. [C:\Users\User\AppData\Local\Temp\pip-install-35qtcmee\pythonnet\src\testing\Python.Test.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\bin\Microsoft.CSharp.CurrentVersion.targets(321,5): error MSB4019: The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\bin\Roslyn\Microsoft.CSharp.Core.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on
disk. [C:\Users\User\AppData\Local\Temp\pip-install-35qtcmee\pythonnet\src\embed_tests\Python.EmbeddingTest.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\bin\Microsoft.CSharp.CurrentVersion.targets(321,5): error MSB4019: The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\bin\Roslyn\Microsoft.CSharp.Core.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on
disk. [C:\Users\User\AppData\Local\Temp\pip-install-35qtcmee\pythonnet\src\console\Console.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\bin\Microsoft.CSharp.CurrentVersion.targets(321,5): error MSB4019: The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\bin\Roslyn\Microsoft.CSharp.Core.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on
disk. [C:\Users\User\AppData\Local\Temp\pip-install-35qtcmee\pythonnet\src\clrmodule\clrmodule.csproj]
??: Error reading msbuild project information, ensure that your input solution or project file is valid. NETCore and UAP projects will be skipped, only packages.config files will be restored.
Restoring NuGet package UnmanagedExports.1.2.7.
Restoring NuGet package NUnit.ConsoleRunner.3.7.0.
Restoring NuGet package NUnit.3.7.1.
Adding package 'NUnit.3.7.1' to folder 'C:\Users\User\AppData\Local\Temp\pip-install-35qtcmee\pythonnet\packages'
Adding package 'NUnit.ConsoleRunner.3.7.0' to folder 'C:\Users\User\AppData\Local\Temp\pip-install-35qtcmee\pythonnet\packages'
Adding package 'UnmanagedExports.1.2.7' to folder 'C:\Users\User\AppData\Local\Temp\pip-install-35qtcmee\pythonnet\packages'
Added package 'NUnit.ConsoleRunner.3.7.0' to folder 'C:\Users\User\AppData\Local\Temp\pip-install-35qtcmee\pythonnet\packages'
Added package 'UnmanagedExports.1.2.7' to folder 'C:\Users\User\AppData\Local\Temp\pip-install-35qtcmee\pythonnet\packages'
Added package 'NUnit.3.7.1' to folder 'C:\Users\User\AppData\Local\Temp\pip-install-35qtcmee\pythonnet\packages'
NuGet Config files used:
C:\Users\User\AppData\Roaming\NuGet\NuGet.Config
Feeds used:
C:\Users\User\.nuget\packages\
https://api.nuget.org/v3/index.json
Installed:
3 package(s) to packages.config projects
Traceback (most recent call last):
File "tools\geninterop\geninterop.py", line 24, in <module>
from pycparser import c_ast, c_parser
ModuleNotFoundError: No module named 'pycparser'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\User\AppData\Local\Temp\pip-install-35qtcmee\pythonnet\setup.py", line 623, in <module>
setup(
File "c:\users\User\appdata\local\programs\python\python38-32\lib\site-packages\setuptools\__init__.py", line 144, in setup
return distutils.core.setup(**attrs)
File "c:\users\User\appdata\local\programs\python\python38-32\lib\distutils\core.py", line 148, in setup
dist.run_commands()
File "c:\users\User\appdata\local\programs\python\python38-32\lib\distutils\dist.py", line 966, in run_commands
self.run_command(cmd)
File "c:\users\User\appdata\local\programs\python\python38-32\lib\distutils\dist.py", line 985, in run_command
cmd_obj.run()
File "C:\Users\User\AppData\Local\Temp\pip-install-35qtcmee\pythonnet\setup.py", line 610, in run
return bdist_wheel.bdist_wheel.run(self)
File "c:\users\User\appdata\local\programs\python\python38-32\lib\site-packages\wheel\bdist_wheel.py", line 223, in run
self.run_command('build')
File "c:\users\User\appdata\local\programs\python\python38-32\lib\distutils\cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "c:\users\User\appdata\local\programs\python\python38-32\lib\distutils\dist.py", line 985, in run_command
cmd_obj.run()
File "c:\users\User\appdata\local\programs\python\python38-32\lib\distutils\command\build.py", line 135, in run
self.run_command(cmd_name)
File "c:\users\User\appdata\local\programs\python\python38-32\lib\distutils\cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "c:\users\User\appdata\local\programs\python\python38-32\lib\distutils\dist.py", line 985, in run_command
cmd_obj.run()
File "c:\users\User\appdata\local\programs\python\python38-32\lib\distutils\command\build_ext.py", line 340, in run
self.build_extensions()
File "c:\users\User\appdata\local\programs\python\python38-32\lib\distutils\command\build_ext.py", line 449, in build_extensions
self._build_extensions_serial()
File "c:\users\User\appdata\local\programs\python\python38-32\lib\distutils\command\build_ext.py", line 474, in _build_extensions_serial
self.build_extension(ext)
File "C:\Users\User\AppData\Local\Temp\pip-install-35qtcmee\pythonnet\setup.py", line 298, in build_extension
subprocess.check_call([sys.executable, geninterop, interop_file])
File "c:\users\User\appdata\local\programs\python\python38-32\lib\subprocess.py", line 364, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['c:\\users\\User\\appdata\\local\\programs\\python\\python38-32\\python.exe', 'tools\\geninterop\\geninterop.py', 'src\\runtime\\interop38.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\User\appdata\local\programs\python\python38-32\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\User\\AppData\\Local\\Temp\\pip-install-35qtcmee\\pythonnet\\setup.py'"'"'; __file__='"'"'C:\\Users\\User\\AppData\\Local\\Temp\\pip-install-35qtcmee\\pythonnet\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\User\AppData\Local\Temp\pip-record-msg167e6\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\User\appdata\local\programs\python\python38-32\Include\pythonnet'
cwd: C:\Users\User\AppData\Local\Temp\pip-install-35qtcmee\pythonnet\
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\User\appdata\local\programs\python\python38-32\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\User\\AppData\\Local\\Temp\\pip-install-35qtcmee\\pythonnet\\setup.py'"'"'; __file__='"'"'C:\\Users\\User\\AppData\\Local\\Temp\\pip-install-35qtcmee\\pythonnet\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\User\AppData\Local\Temp\pip-record-msg167e6\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\User\appdata\local\programs\python\python38-32\Include\pythonnet' Check the logs for full command output.```