(py39 python=3.9) lookme@ubuntu:~/abot_vlm/scripts$ pip install catkin-tools rospkg pyyaml empy numpy -i https://mirrors.bfsu.edu.cn/pypi/web/simple/ Looking in indexes: https://mirrors.bfsu.edu.cn/pypi/web/simple/ Collecting catkin-tools Using cached https://mirrors.bfsu.edu.cn/pypi/web/packages/90/ee/30050750aaebf1f5ea285df83e9463432b8e1798f0a27c1e2ffb1e1a2a91/catkin_tools-0.9.5-py3-none-any.whl (225 kB) Collecting rospkg Using cached https://mirrors.bfsu.edu.cn/pypi/web/packages/fa/c1/b0616243c1f922252ceb4513c22abefc1773cf372bfc0b6f7e59c2829f96/rospkg-1.6.0-py3-none-any.whl (36 kB) Requirement already satisfied: pyyaml in /home/lookme/anaconda3/envs/py39 python=3.9/lib/python3.13/site-packages (6.0.2) Collecting empy Using cached https://mirrors.bfsu.edu.cn/pypi/web/packages/c1/0a/c500fc4c8f48cac08b76b8987070b178f0549534584ac1f414066700a3f9/empy-4.2.tar.gz (166 kB) Preparing metadata (setup.py) ... done Collecting numpy Using cached https://mirrors.bfsu.edu.cn/pypi/web/packages/2e/19/d7c972dfe90a353dbd3efbbe1d14a5951de80c99c9dc1b93cd998d51dc0f/numpy-2.3.1.tar.gz (20.4 MB) Installing build dependencies ... done Getting requirements to build wheel ... done Installing backend dependencies ... done Preparing metadata (pyproject.toml) ... error error: subprocess-exited-with-error × Preparing metadata (pyproject.toml) did not run successfully. │ exit code: 2 ╰─> [103 lines of output] + /home/lookme/anaconda3/envs/py39 python=3.9/bin/python3.1 /tmp/pip-install-hhq1tden/numpy_5a2e309707a0424e99bb980cd1af23ca/vendored-meson/meson/meson.py setup /tmp/pip-install-hhq1tden/numpy_5a2e309707a0424e99bb980cd1af23ca /tmp/pip-install-hhq1tden/numpy_5a2e309707a0424e99bb980cd1af23ca/.mesonpy-62umaclh -Dbuildtype=release -Db_ndebug=if-release -Db_vscrt=md --native-file=/tmp/pip-install-hhq1tden/numpy_5a2e309707a0424e99bb980cd1af23ca/.mesonpy-62umaclh/meson-python-native-file.ini Traceback (most recent call last): File "/tmp/pip-install-hhq1tden/numpy_5a2e309707a0424e99bb980cd1af23ca/vendored-meson/meson/mesonbuild/mesonmain.py", line 193, in run return options.run_func(options) ~~~~~~~~~~~~~~~~^^^^^^^^^ File "/tmp/pip-install-hhq1tden/numpy_5a2e309707a0424e99bb980cd1af23ca/vendored-meson/meson/mesonbuild/msetup.py", line 365, in run app.generate() ~~~~~~~~~~~~^^ File "/tmp/pip-install-hhq1tden/numpy_5a2e309707a0424e99bb980cd1af23ca/vendored-meson/meson/mesonbuild/msetup.py", line 188, in generate return self._generate(env, capture, vslite_ctx) ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/tmp/pip-install-hhq1tden/numpy_5a2e309707a0424e99bb980cd1af23ca/vendored-meson/meson/mesonbuild/msetup.py", line 227, in _generate intr.run() ~~~~~~~~^^ File "/tmp/pip-install-hhq1tden/numpy_5a2e309707a0424e99bb980cd1af23ca/vendored-meson/meson/mesonbuild/interpreter/interpreter.py", line 3065, in run super().run() ~~~~~~~~~~~^^ File "/tmp/pip-install-hhq1tden/numpy_5a2e309707a0424e99bb980cd1af23ca/vendored-meson/meson/mesonbuild/interpreterbase/interpreterbase.py", line 169, in run self.evaluate_codeblock(self.ast, start=1) ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^ File "/tmp/pip-install-hhq1tden/numpy_5a2e309707a0424e99bb980cd1af23ca/vendored-meson/meson/mesonbuild/interpreterbase/interpreterbase.py", line 195, in evaluate_codeblock raise e File "/tmp/pip-install-hhq1tden/numpy_5a2e309707a0424e99bb980cd1af23ca/vendored-meson/meson/mesonbuild/interpreterbase/interpreterbase.py", line 187, in evaluate_codeblock self.evaluate_statement(cur) ~~~~~~~~~~~~~~~~~~~~~~~^^^^^ File "/tmp/pip-install-hhq1tden/numpy_5a2e309707a0424e99bb980cd1af23ca/vendored-meson/meson/mesonbuild/interpreterbase/interpreterbase.py", line 205, in evaluate_statement self.assignment(cur) ~~~~~~~~~~~~~~~^^^^^ File "/tmp/pip-install-hhq1tden/numpy_5a2e309707a0424e99bb980cd1af23ca/vendored-meson/meson/mesonbuild/interpreterbase/interpreterbase.py", line 642, in assignment value = self.evaluate_statement(node.value) File "/tmp/pip-install-hhq1tden/numpy_5a2e309707a0424e99bb980cd1af23ca/vendored-meson/meson/mesonbuild/interpreterbase/interpreterbase.py", line 207, in evaluate_statement return self.method_call(cur) ~~~~~~~~~~~~~~~~^^^^^ File "/tmp/pip-install-hhq1tden/numpy_5a2e309707a0424e99bb980cd1af23ca/vendored-meson/meson/mesonbuild/interpreterbase/interpreterbase.py", line 557, in method_call res = obj.method_call(method_name, args, kwargs) File "/tmp/pip-install-hhq1tden/numpy_5a2e309707a0424e99bb980cd1af23ca/vendored-meson/meson/mesonbuild/interpreterbase/baseobjects.py", line 81, in method_call return method(args, kwargs) File "/tmp/pip-install-hhq1tden/numpy_5a2e309707a0424e99bb980cd1af23ca/vendored-meson/meson/mesonbuild/interpreterbase/decorators.py", line 85, in wrapped ret = f(*wrapped_args, **wrapped_kwargs) File "/tmp/pip-install-hhq1tden/numpy_5a2e309707a0424e99bb980cd1af23ca/vendored-meson/meson/mesonbuild/interpreterbase/decorators.py", line 103, in wrapped return f(*wrapped_args, **wrapped_kwargs) File "/tmp/pip-install-hhq1tden/numpy_5a2e309707a0424e99bb980cd1af23ca/vendored-meson/meson/mesonbuild/interpreterbase/decorators.py", line 806, in wrapped return f(*wrapped_args, **wrapped_kwargs) File "/tmp/pip-install-hhq1tden/numpy_5a2e309707a0424e99bb980cd1af23ca/vendored-meson/meson/mesonbuild/interpreterbase/decorators.py", line 53, in wrapped return f(*wrapped_args, **wrapped_kwargs) File "/tmp/pip-install-hhq1tden/numpy_5a2e309707a0424e99bb980cd1af23ca/vendored-meson/meson/mesonbuild/modules/python.py", line 277, in dependency_method dep = self._dependency_method_impl(kwargs) File "/tmp/pip-install-hhq1tden/numpy_5a2e309707a0424e99bb980cd1af23ca/vendored-meson/meson/mesonbuild/modules/python.py", line 262, in _dependency_method_impl dep = find_external_dependency('python', self.interpreter.environment, new_kwargs, candidates) File "/tmp/pip-install-hhq1tden/numpy_5a2e309707a0424e99bb980cd1af23ca/vendored-meson/meson/mesonbuild/dependencies/detect.py", line 114, in find_external_dependency d = c() File "/tmp/pip-install-hhq1tden/numpy_5a2e309707a0424e99bb980cd1af23ca/vendored-meson/meson/mesonbuild/dependencies/python.py", line 422, in wrap_in_pythons_pc_dir return PythonPkgConfigDependency(name, env, kwargs, installation, True) File "/tmp/pip-install-hhq1tden/numpy_5a2e309707a0424e99bb980cd1af23ca/vendored-meson/meson/mesonbuild/dependencies/python.py", line 326, in __init__ PkgConfigDependency.__init__(self, name, environment, kwargs) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/tmp/pip-install-hhq1tden/numpy_5a2e309707a0424e99bb980cd1af23ca/vendored-meson/meson/mesonbuild/dependencies/pkgconfig.py", line 317, in __init__ self._set_cargs() ~~~~~~~~~~~~~~~^^ File "/tmp/pip-install-hhq1tden/numpy_5a2e309707a0424e99bb980cd1af23ca/vendored-meson/meson/mesonbuild/dependencies/pkgconfig.py", line 372, in _set_cargs cflags = self.pkgconfig.cflags(self.name, allow_system) File "/tmp/pip-install-hhq1tden/numpy_5a2e309707a0424e99bb980cd1af23ca/vendored-meson/meson/mesonbuild/dependencies/pkgconfig.py", line 159, in cflags ret, out, err = self._call_pkgbin(args, env=env) ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^ File "/tmp/pip-install-hhq1tden/numpy_5a2e309707a0424e99bb980cd1af23ca/vendored-meson/meson/mesonbuild/dependencies/pkgconfig.py", line 288, in _call_pkgbin p, out, err = Popen_safe_logged(cmd, env=env) ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^ File "/tmp/pip-install-hhq1tden/numpy_5a2e309707a0424e99bb980cd1af23ca/vendored-meson/meson/mesonbuild/utils/universal.py", line 1588, in Popen_safe_logged p, o, e = Popen_safe(args, **kwargs) ~~~~~~~~~~^^^^^^^^^^^^^^^^ File "/tmp/pip-install-hhq1tden/numpy_5a2e309707a0424e99bb980cd1af23ca/vendored-meson/meson/mesonbuild/utils/universal.py", line 1546, in Popen_safe o, e = p.communicate(write) ~~~~~~~~~~~~~^^^^^^^ File "/home/lookme/anaconda3/envs/py39 python=3.9/lib/python3.13/subprocess.py", line 1222, in communicate stdout, stderr = self._communicate(input, endtime, timeout) ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/lookme/anaconda3/envs/py39 python=3.9/lib/python3.13/subprocess.py", line 2169, in _communicate stdout = self._translate_newlines(stdout, self.stdout.encoding, self.stdout.errors) File "/home/lookme/anaconda3/envs/py39 python=3.9/lib/python3.13/subprocess.py", line 1099, in _translate_newlines data = data.decode(encoding, errors) UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc2 in position 35: invalid continuation byte The Meson build system Version: 1.6.1 Source dir: /tmp/pip-install-hhq1tden/numpy_5a2e309707a0424e99bb980cd1af23ca Build dir: /tmp/pip-install-hhq1tden/numpy_5a2e309707a0424e99bb980cd1af23ca/.mesonpy-62umaclh Build type: native build Project name: NumPy Project version: 2.3.1 C compiler for the host machine: cc (gcc 9.4.0 "cc (Ubuntu 9.4.0-1ubuntu1~18.04) 9.4.0") C linker for the host machine: cc ld.bfd 2.30 C++ compiler for the host machine: c++ (gcc 9.4.0 "c++ (Ubuntu 9.4.0-1ubuntu1~18.04) 9.4.0") C++ linker for the host machine: c++ ld.bfd 2.30 Cython compiler for the host machine: cython (cython 3.1.2) Host machine cpu family: x86_64 Host machine cpu: x86_64 Program python found: YES (/home/lookme/anaconda3/envs/py39 python=3.9/bin/python3.1) Found pkg-config: YES (/usr/bin/pkg-config) 0.29.1 ../meson.build:41:12: ERROR: Unhandled python exception This is a Meson bug and should be reported! [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.
时间: 2025-07-21 18:03:55 浏览: 6
<think>我们遇到了在安装numpy时出现的错误,错误信息显示在准备元数据(pyproject.toml)时失败。从输出中可以看到,具体错误是UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc2 in position 35: invalid continuation byte。
这个错误通常发生在使用非UTF-8编码的环境下,但这里的具体错误是在子进程通信中尝试解码输出时发生的。从堆栈跟踪看,错误发生在Meson构建系统内部,可能是由于pkg-config的输出包含非UTF-8字符。
考虑到我们是在一个中文环境下(Ubuntu系统),但错误信息中出现了字节0xc2,这通常是UTF-8编码中多字节字符的一部分。可能的原因包括:
1. 系统环境变量(如LANG, LC_ALL)设置不正确,导致pkg-config输出非UTF-8字符。
2. 在构建过程中,某个文件的路径包含非ASCII字符(但这里路径看起来是ASCII)。
3. 系统或环境中的某个工具输出了非UTF-8字符。
解决方案:
1. 尝试设置环境变量为UTF-8编码:
在运行pip命令前,执行:
export LC_ALL=C.UTF-8
export LANG=C.UTF-8
2. 如果上述方法无效,可以尝试更新pip和setuptools:
pip install --upgrade pip setuptools
3. 如果问题仍然存在,可以尝试使用conda安装numpy(如果使用conda环境):
conda install numpy
4. 或者,尝试安装预编译的二进制包(wheel):
确保你的系统有安装构建工具(如gcc, g++等),然后尝试使用以下命令强制pip使用二进制包(如果可用):
pip install numpy --only-binary=:all:
5. 如果上述方法都不行,可以尝试从源码安装numpy,但先确保环境正确:
pip install numpy --no-binary=:all:
但是,由于错误发生在Meson构建过程中,而Meson是numpy构建的依赖,我们也可以尝试安装Meson的更新版本(但numpy的安装应该会自动处理)。
根据错误提示,这可能是Meson的一个bug,但我们可以尝试更新Meson:
pip install --upgrade meson
注意:我们是在一个conda环境中(环境名为'py39 python=3.9',但注意环境名中有空格,可能会引起问题,但这里路径显示正常)。
步骤总结:
首先尝试设置环境变量为UTF-8,然后重新安装。
具体命令如下:
```
export LC_ALL=C.UTF-8
export LANG=C.UTF-8
pip install numpy -i https://mirrors.bfsu.edu.cn/pypi/web/simple/
```
如果问题依旧,尝试升级pip和setuptools,然后再次安装。
如果仍然不行,尝试使用conda安装(如果这个环境是conda环境):
```
conda install numpy
```
或者,使用--only-binary选项:
```
pip install numpy --only-binary=:all: -i https://mirrors.bfsu.edu.cn/pypi/web/simple/
```
最后,如果所有方法都失败,考虑报告bug给numpy或meson。
由于我们是在安装多个包(catkin-tools, rospkg, empy, numpy)时出现的问题,但其他包都安装成功,只有numpy失败,所以可以单独安装numpy。
注意:在安装过程中,我们看到numpy的版本是2.3.1(最新版本),也可以尝试安装一个更稳定的版本,例如:
```
pip install numpy==1.24.4 -i https://mirrors.bfsu.edu.cn/pypi/web/simple/
```
因为最新版本可能存在兼容性问题。
现在,我们按照上述思路提供解决方案。</think>### 解决 NumPy 安装失败问题
您遇到的错误是由于 NumPy 2.3.1 在构建过程中与 Python 3.13 环境存在兼容性问题(Unicode 解码错误)。以下是完整的解决方案:
#### 解决方案步骤:
1. **升级构建工具**:
```bash
pip install --upgrade pip setuptools wheel
```
2. **安装兼容的 NumPy 版本**(推荐稳定版本):
```bash
pip install numpy==1.24.4 -i https://mirrors.bfsu.edu.cn/pypi/web/simple/
```
3. **如果仍需最新版**,尝试二进制安装:
```bash
pip install numpy --only-binary=:all: -i https://mirrors.bfsu.edu.cn/pypi/web/simple/
```
4. **修复环境变量**(解决 Unicode 错误):
```bash
export LC_ALL=C.UTF-8
export LANG=C.UTF-8
# 然后重新运行安装命令
```
5. **验证安装**:
```bash
python -c "import numpy; print(numpy.__version__)"
```
#### 备选方案:
- 使用 Conda 安装(如果环境支持):
```bash
conda install numpy
```
- 安装构建依赖:
```bash
sudo apt-get install build-essential python3-dev
```
#### 错误分析:
1. 根本原因:NumPy 2.3.1 的构建系统(Meson)与 Python 3.13 存在兼容性问题
2. 关键报错:`UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc2`
3. 环境冲突:Conda 环境与系统编译工具链不匹配
阅读全文
相关推荐















