You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ubuntu 22.04下给PyPy安装SciPy遇语法错误如何解决

在Ubuntu 22.04上为PyPy3安装SciPy时的引号转义问题

我使用Ubuntu 22.04 "Jammy"系统,已安装PyPy3。尝试执行以下命令为PyPy3升级安装SciPy时:

pypy3 -m pip install scipy --upgrade

出现了如下错误:

ndos@ndos-desktop:~$ pypy3 -m pip install scipy --upgrade
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: scipy in /usr/lib/python3/dist-packages (1.8.0)
Collecting scipy
Using cached scipy-1.9.0.tar.gz (42.0 MB)
Installing build dependencies ... done
Getting requirements to build wheel ... error
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> [54 lines of output]
    The Meson build system
    Version: 0.62.2
    Source dir: /tmp/pip-install-2ov2xi0h/scipy_8ec7415f7e94440e82d27b79cc387e5d
    Build dir: /tmp/pip-install-2ov2xi0h/scipy_8ec7415f7e94440e82d27b79cc387e5d/.mesonpy-mv4soouy/build
    Build type: native build
    Project name: SciPy
    Project version: 1.9.0
    C compiler for the host machine: cc (gcc 11.2.0 "cc (Ubuntu 11.2.0-19ubuntu1) 11.2.0")
    C linker for the host machine: cc ld.bfd 2.38
    C++ compiler for the host machine: c++ (gcc 11.2.0 "c++ (Ubuntu 11.2.0-19ubuntu1) 11.2.0")
    C++ linker for the host machine: c++ ld.bfd 2.38
    Host machine cpu family: x86_64
    Host machine cpu: x86_64
    Compiler for C supports arguments -Wno-unused-but-set-variable: YES
    Library m found: YES
    Fortran compiler for the host machine: gfortran (gcc 11.2.0 "GNU Fortran (Ubuntu 11.2.0-19ubuntu1) 11.2.0")
    Fortran linker for the host machine: gfortran ld.bfd 2.38
    Program cython found: YES (/tmp/pip-build-env-ndkikzz6/overlay/bin/cython)
    Program pythran found: YES (/tmp/pip-build-env-ndkikzz6/overlay/bin/pythran)
    Program cp found: YES (/usr/bin/cp)
    Program python3 found: YES (/usr/bin/pypy3)
    
    ../../scipy/meson.build:40:0: ERROR: Command "/usr/bin/pypy3 -c import os; os.chdir(".."); import numpy; print(numpy.get_include())" failed with status 1.
    
    A full log can be found at /tmp/pip-install-2ov2xi0h/scipy_8ec7415f7e94440e82d27b79cc387e5d/.mesonpy-mv4soouy/build/meson-logs/meson-log.txt
    + meson setup --native-file=/tmp/pip-install-2ov2xi0h/scipy_8ec7415f7e94440e82d27b79cc387e5d/.mesonpy-native-file.ini -Ddebug=false -Doptimization=2 --prefix=/usr /tmp/pip-install-2ov2xi0h/scipy_8ec7415f7e94440e82d27b79cc387e5d /tmp/pip-install-2ov2xi0h/scipy_8ec7415f7e94440e82d27b79cc387e5d/.mesonpy-mv4soouy/build
    Traceback (most recent call last):
        File "/home/ndos/.local/lib/pypy3.8/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, in <module>
        main()
        File "/home/ndos/.local/lib/pypy3.8/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 345, in main
        json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/home/ndos/.local/lib/pypy3.8/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 130, in get_requires_for_build_wheel
        return hook(config_settings)
        File "/tmp/pip-build-env-ndkikzz6/overlay/lib/pypy3.8/site-packages/mesonpy/__init__.py", line 909, in get_requires_for_build_wheel
        with _project(config_settings) as project:
        File "/usr/lib/pypy3.8/contextlib.py", line 113, in __enter__
        return next(self.gen)
        File "/tmp/pip-build-env-ndkikzz6/overlay/lib/pypy3.8/site-packages/mesonpy/__init__.py", line 889, in _project
        build_dir=config_settings.get('builddir'),
        File "/usr/lib/pypy3.8/contextlib.py", line 113, in __enter__
        return next(self.gen)
        File "/tmp/pip-build-env-ndkikzz6/overlay/lib/pypy3.8/site-packages/mesonpy/__init__.py", line 547, in with_temp_working_dir
        yield cls(source_dir, tmpdir, build_dir)
        File "/tmp/pip-build-env-ndkikzz6/overlay/lib/pypy3.8/site-packages/mesonpy/__init__.py", line 463, in __init__
        self._configure(reconfigure=bool(build_dir) and not native_file_mismatch)
        File "/tmp/pip-build-env-ndkikzz6/overlay/lib/pypy3.8/site-packages/mesonpy/__init__.py", line 500, in _configure
        *setup_args,
        File "/tmp/pip-build-env-ndkikzz6/overlay/lib/pypy3.8/site-packages/mesonpy/__init__.py", line 477, in _meson
        return self._proc('meson', *args)
        File "/tmp/pip-build-env-ndkikzz6/overlay/lib/pypy3.8/site-packages/mesonpy/__init__.py", line 472, in _proc
        subprocess.check_call(list(args))
        File "/usr/lib/pypy3.8/subprocess.py", line 364, in check_call
        raise CalledProcessError(retcode, cmd)
    subprocess.CalledProcessError: Command '['meson', 'setup', '--native-file=/tmp/pip-install-2ov2xi0h/scipy_8ec7415f7e94440e82d27b79cc387e5d/.mesonpy-native-file.ini', '-Ddebug=false', '-Doptimization=2', '--prefix=/usr', '/tmp/pip-install-2ov2xi0h/scipy_8ec7415f7e94440e82d27b79cc387e5d', '/tmp/pip-install-2ov2xi0h/scipy_8ec7415f7e94440e82d27b79cc387e5d/.mesonpy-mv4soouy/build']' returned non-zero exit status 1.
    [end of output]

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

× Getting requirements to build wheel 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.

我定位到了关键错误行:

../../scipy/meson.build:40:0: ERROR: Command "/usr/bin/pypy3 -c import os; os.chdir(".."); import numpy; print(numpy.get_include())" failed with status 1.

我明白这个命令因为嵌套双引号导致无效,应该转义内部双引号或者替换为单引号,但不知道具体该怎么解决这个问题?

内容的提问来源于stack exchange,提问作者Dannyu NDos

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.24 16:54:52