我用下面的命令将轮子、pip和setuptools升级到最新版本。
pip3.9 install --upgrade pip setuptools wheel
当我尝试安装opencv pip3.9 install opencv-python
时,会出现一个错误。我试着安装一个旧版本,得到了相同的错误(4.5.5.62
)。这是我遇到的错误,请看一看,谢谢!
Python版本: 3.9 (opencv-python在3.8岁时工作)
应用: PyCharm
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, in <module>
main()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 345, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 261, in build_wheel
return _build_backend().build_wheel(wheel_directory, config_settings,
File "/private/var/folders/0v/j0nhw8p50yd3_w61mysphgjc0000gn/T/pip-build-env-rp7pv38q/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 244, in build_wheel
return self._build_with_temp_dir(['bdist_wheel'], '.whl',
File "/private/var/folders/0v/j0nhw8p50yd3_w61mysphgjc0000gn/T/pip-build-env-rp7pv38q/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 229, in _build_with_temp_dir
self.run_setup()
File "/private/var/folders/0v/j0nhw8p50yd3_w61mysphgjc0000gn/T/pip-build-env-rp7pv38q/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 281, in run_setup
super(_BuildMetaLegacyBackend,
File "/private/var/folders/0v/j0nhw8p50yd3_w61mysphgjc0000gn/T/pip-build-env-rp7pv38q/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 174, in run_setup
exec(compile(code, __file__, 'exec'), locals())
File "setup.py", line 502, in <module>
main()
File "setup.py", line 239, in main
skbuild.setup(
File "/private/var/folders/0v/j0nhw8p50yd3_w61mysphgjc0000gn/T/pip-build-env-rp7pv38q/overlay/lib/python3.9/site-packages/skbuild/setuptools_wrap.py", line 676, in setup
_classify_installed_files(
File "setup.py", line 442, in _classify_installed_files_override
return (cls.wraps._classify_installed_files)(
TypeError: _classify_installed_files() got an unexpected keyword argument 'cmake_install_dir'
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for opencv-python
Failed to build opencv-python
ERROR: Could not build wheels for opencv-python, which is required to install pyproject.toml-based projects
发布于 2022-09-16 14:40:04
通过检查函数cls.wraps._classify_installed_files
的源。
print(inspect.getsource(cls.wraps._classify_installed_files))
我发现原因是函数定义中没有名为cmake_install_dir
的参数,而是_cmake_install_dir
参数。
def _classify_installed_files(
install_paths,
package_data,
package_prefixes,
py_modules,
new_py_modules,
scripts,
new_scripts,
data_files,
cmake_source_dir,
_cmake_install_dir,
):
assert not os.path.isabs(cmake_source_dir)
assert cmake_source_dir != "."
install_root = os.path.join(os.getcwd(), CMAKE_INSTALL_DIR())
......
因此,我将命名参数cmake_install_dir
更改为_cmake_install_dir
。然后通过了!
return (cls.wraps._classify_installed_files)(
final_install_paths,
package_data,
package_prefixes,
py_modules,
new_py_modules,
scripts,
new_scripts,
data_files,
# To get around a check that prepends source dir to paths and breaks package detection code.
cmake_source_dir="",
_cmake_install_dir=cmake_install_reldir,
)
https://stackoverflow.com/questions/71870382
复制相似问题