问题遇到的现象和发生背景
我想安装个toga库,但是出现了以下错误:
问题相关代码,请勿粘贴截图
pip install toga
运行结果及报错内容
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting toga
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/b6/d3/655e023785ccfdb62c7f13173112b2e5ae5b507bf595852d0333ca8cd9fd/toga-0.2.15-py3-none-any.whl (4.3 kB)
Collecting toga-winforms
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/90/60/a60421638a8028eee8dba3548c0082845f76720053e01a75a29a72c1ad4c/toga_winforms-0.2.15-py3-none-any.whl (13 kB)
Collecting pythonnet
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/f7/18/be276f27f649199563a59561623c0c008e72bbcb6ecb8b2ca0404a741ae1/pythonnet-2.5.2.tar.gz (1.9 MB)
Preparing metadata (setup.py) ... done
Requirement already satisfied: toga-core>=0.2.15 in c:\program files\python39\lib\site-packages (from toga-winforms->toga) (0.2.15)
Requirement already satisfied: colosseum>=0.1.6 in c:\program files\python39\lib\site-packages (from toga-core>=0.2.15->toga-winforms->toga) (0.2.0)
Requirement already satisfied: pycparser in c:\program files\python39\lib\site-packages (from pythonnet->toga-winforms->toga) (2.21)
Building wheels for collected packages: pythonnet
Building wheel for pythonnet (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py bdist_wheel did not run successfully.
│ exit code: 1
╰─> [57 lines of output]
running bdist_wheel
running build
running build_ext
正在检查来自 https://www.nuget.org/api/v2/ 的更新。
当前正在运行 NuGet.exe 4.1.0。
正在将 NuGet.exe 更新到 6.2.1。
操作已超时。
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 34, in <module>
File "%Temp%\pip-install-dx2g31wo\pythonnet_640d098f90f44a948b6128ffd80ae5ef\setup.py", line 630, in <module>
setup(
File "C:\Program Files\Python39\lib\site-packages\setuptools\__init__.py", line 87, in setup
return distutils.core.setup(**attrs)
File "C:\Program Files\Python39\lib\site-packages\setuptools\_distutils\core.py", line 185, in setup
return run_commands(dist)
File "C:\Program Files\Python39\lib\site-packages\setuptools\_distutils\core.py", line 201, in run_commands
dist.run_commands()
File "C:\Program Files\Python39\lib\site-packages\setuptools\_distutils\dist.py", line 973, in run_commands
self.run_command(cmd)
File "C:\Program Files\Python39\lib\site-packages\setuptools\dist.py", line 1217, in run_command
super().run_command(command)
File "C:\Program Files\Python39\lib\site-packages\setuptools\_distutils\dist.py", line 992, in run_command
cmd_obj.run()
File "%Temp%\pip-install-dx2g31wo\pythonnet_640d098f90f44a948b6128ffd80ae5ef\setup.py", line 612, in run
return bdist_wheel.bdist_wheel.run(self)
File "C:\Program Files\Python39\lib\site-packages\wheel\bdist_wheel.py", line 299, in run
self.run_command('build')
File "C:\Program Files\Python39\lib\site-packages\setuptools\_distutils\cmd.py", line 319, in run_command
self.distribution.run_command(command)
File "C:\Program Files\Python39\lib\site-packages\setuptools\dist.py", line 1217, in run_command
super().run_command(command)
File "C:\Program Files\Python39\lib\site-packages\setuptools\_distutils\dist.py", line 992, in run_command
cmd_obj.run()
File "C:\Program Files\Python39\lib\site-packages\setuptools\command\build.py", line 24, in run
super().run()
╰─> [6 lines of output]
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
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure
× Encountered error while trying to install package.
╰─> pythonnet
note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
我的解答思路和尝试过的方法
python.exe -m pip install --upgrade pip
无效
pip3 uninstall setuptools
pip3 install setuptools
这个方法也无效,只解决了上一个
我想要达到的结果
成功安装toga包