ubuntu 2014.4 python 3 安装

本文详细介绍了在Ubuntu系统中安装Python3.6的具体步骤,包括添加安装包、下载并设置Python3.6为默认版本,以及解决pip升级过程中遇到的问题。特别针对pip安装失败的情况提供了手动下载源码安装的方法,确保Python环境配置的顺利完成。

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

依据网上大神按照下面的步骤进行安装

1.添加python3.6安装包,并且安装

sudo apt-get install software-properties-common

2.下载python3.6

sudo add-apt-repository ppa:jonathonf/python-3.6
sudo apt-get update
sudo apt-get install python3.6

2.修改系统默认python版本为3.6,并更新

cd /user/bin
rm python
ln -s python3.6m python
python pip install --upgrade pip

最后一步的时候出问题了

apuser@bj01976pcu1:/usr/bin$ python pip install --upgrade pip
Traceback (most recent call last):
  File "pip", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/usr/lib/python3/dist-packages/pkg_resources.py", line 1479, in <module>
    register_loader_type(importlib_bootstrap.SourceFileLoader, DefaultProvider)
AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'
 

手动下载pip源码进行安装,

执行 python setup.py install 

安装的过程中有可能会出现“ImportError: No module named setuptools”的错误提示,这是因为Windows环境下Python默认是没有安装setuptools这个模块的,这也是一个第三方模块。

只需要下载https://bootstrap.pypa.io/ez_setup.py 自动化安装脚本,并运行即可自动判别python版本进行自动化安装,之后再运行 python setup.py install 即可自动安装第三方模块了

最后 执行 python setup.py install 之后 安装完成

removing 'build/bdist.linux-x86_64/egg' (and everything under it)
Processing pip-19.1.1-py3.6.egg
creating /usr/local/lib/python3.6/dist-packages/pip-19.1.1-py3.6.egg
Extracting pip-19.1.1-py3.6.egg to /usr/local/lib/python3.6/dist-packages
Adding pip 19.1.1 to easy-install.pth file
Installing pip script to /usr/local/bin
Installing pip3 script to /usr/local/bin
Installing pip3.6 script to /usr/local/bin

ubuntu@raspberrypi:~$ bash ./PX4-Autopilot/Tools/setup/ubuntu.sh --fix-missing [ubuntu.sh] Starting... [ubuntu.sh] arch: aarch64 [ubuntu.sh] Ubuntu 20.04 [ubuntu.sh] Installing PX4 general dependencies Hit:1 http://mirrors.tuna.tsinghua.edu.cn/ros/ubuntu focal InRelease Hit:2 http://mirrors.tuna.tsinghua.edu.cn/ros2/ubuntu focal InRelease Hit:3 https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports focal InRelease Hit:4 https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports focal-updates InRelease Hit:5 https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports focal-backports InRelease Hit:6 https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports focal-security InRelease Reading package lists... Reading package lists... Building dependency tree... Reading state information... ccache is already the newest version (3.7.7-1). file is already the newest version (1:5.38-4). g++ is already the newest version (4:9.3.0-1ubuntu2). gcc is already the newest version (4:9.3.0-1ubuntu2). make is already the newest version (4.2.1-1.2). python3 is already the newest version (3.8.2-0ubuntu2). python3-dev is already the newest version (3.8.2-0ubuntu2). zip is already the newest version (3.0-11build1). astyle is already the newest version (3.1-2build1). cppcheck is already the newest version (1.90-4build1). lcov is already the newest version (1.14-2). ninja-build is already the newest version (1.10.0-1build1). shellcheck is already the newest version (0.7.0-2build2). build-essential is already the newest version (12.8ubuntu1.1). cmake is already the newest version (3.16.3-1ubuntu1.20.04.1). gdb is already the newest version (9.2-0ubuntu1~20.04.2). git is already the newest version (1:2.25.1-1ubuntu3.14). git set to manually installed. libssl-dev is already the newest version (1.1.1f-1ubuntu2.24). libxml2-dev is already the newest version (2.9.10+dfsg-5ubuntu0.20.04.10). libxml2-utils is already the newest version (2.9.10+dfsg-5ubuntu0.20.04.10). python3-setuptools is already the newest version (45.2.0-1ubuntu0.3). rsync is already the newest version (3.1.3-8ubuntu0.9). rsync set to manually installed. unzip is already the newest version (6.0-25ubuntu1.2). python3-pip is already the newest version (20.0.2-5ubuntu1.11). python3-wheel is already the newest version (0.34.2-1ubuntu0.1). 0 upgraded, 0 newly installed, 0 to remove and 163 not upgraded. [ubuntu.sh] Installing PX4 Python3 dependencies Collecting argcomplete (from -r /home/ubuntu/PX4-Autopilot/Tools/setup/requirements.txt (line 1)) Downloading argcomplete-3.6.2-py3-none-any.whl.metadata (16 kB) Collecting cerberus (from -r /home/ubuntu/PX4-Autopilot/Tools/setup/requirements.txt (line 2)) Downloading Cerberus-1.3.7-py3-none-any.whl.metadata (5.5 kB) Collecting coverage (from -r /home/ubuntu/PX4-Autopilot/Tools/setup/requirements.txt (line 3)) Downloading coverage-7.6.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.metadata (8.3 kB) Requirement already satisfied: empy<4,>=3.3 in /usr/lib/python3/dist-packages (from -r /home/ubuntu/PX4-Autopilot/Tools/setup/requirements.txt (line 4)) (3.3.2) Requirement already satisfied: future in /usr/lib/python3/dist-packages (from -r /home/ubuntu/PX4-Autopilot/Tools/setup/requirements.txt (line 5)) (0.18.2) Requirement already satisfied: jinja2>=2.8 in /usr/lib/python3/dist-packages (from -r /home/ubuntu/PX4-Autopilot/Tools/setup/requirements.txt (line 6)) (2.10.1) Requirement already satisfied: jsonschema in /usr/lib/python3/dist-packages (from -r /home/ubuntu/PX4-Autopilot/Tools/setup/requirements.txt (line 7)) (3.2.0) Collecting kconfiglib (from -r /home/ubuntu/PX4-Autopilot/Tools/setup/requirements.txt (line 8)) Downloading kconfiglib-14.1.0-py2.py3-none-any.whl.metadata (39 kB) Collecting lxml (from -r /home/ubuntu/PX4-Autopilot/Tools/setup/requirements.txt (line 9)) Downloading lxml-6.0.0.tar.gz (4.1 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4.1/4.1 MB 4.0 MB/s eta 0:00:00 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 ╰─> [3 lines of output] Building lxml version 6.0.0. Building without Cython. Error: Please make sure the libxml2 and libxslt development packages are installed. [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.
最新发布
08-10
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值