【ubuntu18.04】meson 安装 及python升级python3.9

本文介绍了在Ubuntu 18.04上安装meson的过程,以及如何从Python3.6升级到Python3.9。首先确保已安装python3.5以上版本,然后通过pip3安装meson,由于meson安装在~/.local/bin,需要更新PATH。接着,卸载Python3.6并安装Python3.9,最后通过软链接使系统默认使用Python3.9,并验证meson的安装。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

(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.
最新发布
07-14
### 安装 Python 3.9 的过程 #### 准备工作 为了确保顺利安装 Python 3.9,在开始之前需要先更新系统的包列表并安装必要的依赖项。 ```bash sudo apt-get update && sudo apt-get upgrade -y sudo apt-get install -y build-essential zlib1g-dev libncurses5-dev \ libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev curl \ libbz2-dev libsqlite3-dev wget liblzma-dev tk-dev openssl git ``` #### 下载 Python 源代码 访问官方 Python 网站下载最新版的 Python 3.9 源码压缩包,解压后进入目录准备编译环境。 ```bash cd /usr/src sudo wget https://www.python.org/ftp/python/3.9.0/Python-3.9.0.tgz sudo tar xzf Python-3.9.0.tgz cd Python-3.9.0 ``` #### 编译与安装 配置构建选项,并通过 `make` 命令来编译源代码。为了避免覆盖现有的默认 Python 版本,建议使用 `make altinstall` 来代替普通的 `make install` 进行安装[^1]。 ```bash ./configure --enable-optimizations sudo make altinstall ``` #### 创建符号链接 为了让新版本的 Python 解释器可以通过命令行直接调用,创建指向 `/usr/local/bin/python3.9` 和 pip 工具的符号链接至标准路径下[^2]。 ```bash ln -s /usr/local/bin/python3.9 /usr/bin/python3.9 ln -s /usr/local/bin/pip3.9 /usr/bin/pip3.9 ``` #### 更新替代方案 (Optional) 如果希望进一步管理不同版本之间的切换,可以利用 Ubuntu 自带的选择工具设置优先级较高的 Python 版本作为默认解释器[^3]。 ```bash sudo update-alternatives --install /usr/bin/python python /usr/local/bin/python3.9 1 sudo update-alternatives --config python ``` 完成上述操作之后,就可以成功在 Ubuntu 18.04安装并配置好 Python 3.9 环境了。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

等风来不如迎风去

你的鼓励是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值