Ultralytics 未安装在 pycharm 中

问题描述 投票:0回答:1

我在笔记本电脑上尝试在 PyCharm 中重新安装 ultralytics 库时遇到问题。尽管没有对我的系统配置进行任何更改,但安装过程现在失败,并出现与 GCC 编译器相关的错误。

这令人费解,因为我之前已经成功安装了ultralytics,没有遇到任何问题。该错误消息表明 GCC 安装或其配置可能存在问题,即使我没有修改任何相关内容。

我需要进一步调查以确定错误的确切原因并找到解决方案。这可能涉及检查 GCC 安装是否存在任何不一致、验证其在环境变量中的路径,或确保 PyCharm 的 Python 解释器配置正确。错误图片

> Collecting ultralytics

Using cached ultralytics-8.3.7-py3-none-any.whl.metadata (34 kB)
Collecting numpy\>=1.23.0 (from ultralytics)
Using cached numpy-2.1.2-cp313-cp313-win_amd64.whl.metadata (59 kB)
Collecting matplotlib\>=3.3.0 (from ultralytics)
Using cached matplotlib-3.9.2-cp313-cp313-win_amd64.whl.metadata (11 kB)
Collecting opencv-python\>=4.6.0 (from ultralytics)
Using cached opencv_python-4.10.0.84-cp37-abi3-win_amd64.whl.metadata (20 kB)
Collecting pillow\>=7.1.2 (from ultralytics)
Using cached pillow-10.4.0-cp313-cp313-win_amd64.whl.metadata (9.3 kB)
Collecting pyyaml\>=5.3.1 (from ultralytics)
Using cached PyYAML-6.0.2-cp313-cp313-win_amd64.whl.metadata (2.1 kB)
Collecting requests\>=2.23.0 (from ultralytics)
Using cached requests-2.32.3-py3-none-any.whl.metadata (4.6 kB)
Collecting scipy\>=1.4.1 (from ultralytics)
Using cached scipy-1.14.1-cp313-cp313-win_amd64.whl.metadata (60 kB)
INFO: pip is looking at multiple versions of ultralytics to determine which version is compatible with other requirements. This could take a while.
Collecting ultralytics
Using cached ultralytics-8.3.6-py3-none-any.whl.metadata (34 kB)
Using cached ultralytics-8.3.5-py3-none-any.whl.metadata (34 kB)
Using cached ultralytics-8.3.4-py3-none-any.whl.metadata (34 kB)
Using cached ultralytics-8.3.3-py3-none-any.whl.metadata (34 kB)
Collecting numpy\<2.0.0,\>=1.23.0 (from ultralytics)
Using cached numpy-1.26.4.tar.gz (15.8 MB)
Installing build dependencies: started
Installing build dependencies: finished with status 'done'
Getting requirements to build wheel: started
Getting requirements to build wheel: finished with status 'done'
Installing backend dependencies: started
Installing backend dependencies: finished with status 'done'
Preparing metadata (pyproject.toml): started
Preparing metadata (pyproject.toml): finished with status 'error'

error: subprocess-exited-with-error

Preparing metadata (pyproject.toml) did not run successfully.
exit code: 1

\[19 lines of output\]
D:\\Coding Room\\Python.venv\\Scripts\\python.exe C:\\Users\\HP\\AppData\\Local\\Temp\\pip-install-hwheu7pa\\numpy_dc50f60de418499a95217a394754e949\\vendored-meson\\meson\\meson.py setup C:\\Users\\HP\\AppData\\Local\\Temp\\pip-install-hwheu7pa\\numpy_dc50f60de418499a95217a394754e949 C:\\Users\\HP\\AppData\\Local\\Temp\\pip-install-hwheu7pa\\numpy_dc50f60de418499a95217a394754e949.mesonpy-kpbmsnul -Dbuildtype=release -Db_ndebug=if-release -Db_vscrt=md --native-file=C:\\Users\\HP\\AppData\\Local\\Temp\\pip-install-hwheu7pa\\numpy_dc50f60de418499a95217a394754e949.mesonpy-kpbmsnul\\meson-python-native-file.ini
The Meson build system
Version: 1.2.99
Source dir: C:\\Users\\HP\\AppData\\Local\\Temp\\pip-install-hwheu7pa\\numpy_dc50f60de418499a95217a394754e949
Build dir: C:\\Users\\HP\\AppData\\Local\\Temp\\pip-install-hwheu7pa\\numpy_dc50f60de418499a95217a394754e949.mesonpy-kpbmsnul
Build type: native build
Project name: NumPy
Project version: 1.26.4
C compiler for the host machine: gcc (gcc 6.3.0 "gcc (MinGW.org GCC-6.3.0-1) 6.3.0")
C linker for the host machine: gcc ld.bfd 2.28
C++ compiler for the host machine: c++ (gcc 6.3.0 "c++ (MinGW.org GCC-6.3.0-1) 6.3.0")
C++ linker for the host machine: c++ ld.bfd 2.28
Cython compiler for the host machine: cython (cython 3.0.11)
Host machine cpu family: x86
Host machine cpu: x86

..\\meson.build:28:4: ERROR: Problem encountered: NumPy requires GCC \>= 8.4

A full log can be found at C:\\Users\\HP\\AppData\\Local\\Temp\\pip-install-hwheu7pa\\numpy_dc50f60de418499a95217a394754e949.mesonpy-kpbmsnul\\meson-logs\\meson-log.txt
\[end of output\]

note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

Encountered error while generating package metadata.

See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
python pip pycharm ultralytics
1个回答
0
投票

明显的错误是 gcc 版本太低,但是当在 Windows 机器上从源代码编译 numpy 时,已经出现了“错误”。这意味着您使用的 python 版本(看起来像 3.13)与您需要的 numpy 版本不兼容 (

numpy\<2.0.0,\>=1.23.0
)。Numpy 1.26.4 的 whl 文件最高可达 python 3.12。

我猜你已经在新设置中切换到了新的 python 版本,也许是因为你有多个并且你的新 Pycharm 选择了 3.13,而你的旧版本被配置为使用另一个版本。

检查您的设置并配置不同的 python 版本 <3.13 in your project settings. Then attempt to install again

© www.soinside.com 2019 - 2024. All rights reserved.