meson-python:错误:安装pandas时找不到版本1.8.2或更新的ninja

0 投票
1 回答
52 浏览
提问于 2025-04-13 03:00

我正在通过 Namecheap 的共享主机部署我的 Django 应用,使用的是 cPanel 的终端。我的项目有一些依赖项在 requirements.txt 文件里。我在终端中安装这些依赖,但在安装 numpy 或 pandas 时遇到了错误。问题是我已经安装了 ninja 版本 1.11.1,而需要的版本是 1.8.2 或更新的版本,所以系统根本没有检测到 ninja。我也尝试过降级 ninja 的版本和不同的组合,但都没有成功。希望能得到一些帮助。

((app:3.11)) [abc@server123 simply]$ pip install pandas
Collecting pandas
  Using cached pandas-2.2.1.tar.gz (4.4 MB)
  Installing build dependencies ... error
  error: subprocess-exited-with-error

  × pip subprocess to install build dependencies did not run successfully.
  │ exit code: 1
  ╰─> [35 lines of output]
      Collecting meson-python==0.13.1
        Using cached meson_python-0.13.1-py3-none-any.whl.metadata (4.1 kB)
      Collecting meson==1.2.1
        Using cached meson-1.2.1-py3-none-any.whl.metadata (1.7 kB)
      Collecting wheel
        Using cached wheel-0.43.0-py3-none-any.whl.metadata (2.2 kB)
      Collecting Cython==3.0.5
        Using cached Cython-3.0.5-py2.py3-none-any.whl.metadata (3.2 kB)
      Collecting numpy<=2.0.0.dev0,>1.22.4
        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
        ╰─> [2 lines of output]

            ('\x1b[31m',)meson-python: error: Could not find ninja version 1.8.2 or newer.
            [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.
      [end of output]

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

× pip subprocess to install build dependencies did not run successfully.
│ exit code: 1
╰─> See above for output.

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

我正在使用

python version 3.11.5
asgiref==3.7.2
Django==5.0.3
PyMySQL==1.1.0
sqlparse==0.4.4
tzdata==2024.1
ninjas==1.11.1
pandas

我尝试通过 GitHub 下载并克隆代码库,但仍然没有成功。

1 个回答

0

使用venv或virtualenv创建一个虚拟环境,这样可以把项目所需的库和系统自带的库分开,避免出现冲突:

python -m venv my_venv 

source my_venv/bin/activate  # Activate the virtual environment

在虚拟环境中安装pandas库:

pip install pandas

如果运行你的Django应用需要用到manage.py,记得在运行之前先激活虚拟环境:

source my_venv/bin/activate

接下来:

python manage.py runserver

撰写回答