树莓派3b的raspberrypi系统安装pip

上节将python的默认版本更改为python3了,我们可以直接使用python命令,该命令就是使用的python3

我们想要通过pip命令安装python扩展包,先安装pip,apt install没用,通过源码安装

PyPI · The Python Package Index查找源码包,首先安装setuptools,再安装pip

pi@raspberrypi:~ $ wget https://files.pythonhosted.org/packages/cf/79/1a19c2f792da00cbead7b6caa176afdddf517522cb9163ce39576025b050/setuptools-57.1.0.tar.gz
pi@raspberrypi:~ $ wget https://files.pythonhosted.org/packages/4d/0c/3b63fe024414a8a48661cf04f0993d4b2b8ef92daed45636474c018cd5b7/pip-21.1.3.tar.gz

  下载之后解压缩

pi@raspberrypi:~ $ tar -zxvf setuptools-57.1.0.tar.gz
pi@raspberrypi:~ $ tar -zxvf pip-21.1.3.tar.gz

  进入解压缩的目录

pi@raspberrypi:~ $ cd setuptools-57.1.0

  直接命令安装setuptools

pi@raspberrypi:~/setuptools-57.1.0 $ sudo python setup.py build
//由于在build时候提示错误No mudule named “distutils.util” ,故安装此部分程序,完美解决问题
pi@raspberrypi:~/setuptools-57.1.0 $ sudo apt install python3-distutils
//继续安装setuptools
pi@raspberrypi:~/setuptools-57.1.0 $ sudo python setup.py build
pi@raspberrypi:~/setuptools-57.1.0 $ sudo python setup.py install

  安装pip

pi@raspberrypi:~ $ cd pip-21.1.3/
pi@raspberrypi:~/pip-21.1.3 $ sudo python setup.py build
pi@raspberrypi:~/pip-21.1.3 $ sudo python setup.py install

  查看pip版本

pi@raspberrypi:~/pip-21.1.3 $ pip --version
pip 21.1.3 from /usr/local/lib/python3.7/dist-packages/pip-21.1.3-py3.7.egg/pip (python 3.7)

  pip安装完成,可以通过pip命令安装扩展包了

pi@raspberrypi:~ $ pip install lxml
Defaulting to user installation because normal site-packages is not writeable
Collecting lxml
  Downloading lxml-4.6.3-cp37-cp37m-manylinux2014_aarch64.whl (6.7 MB)
     |████████████████████████████████| 6.7 MB 73 kB/s
Installing collected packages: lxml
Successfully installed lxml-4.6.3
pi@raspberrypi:~ $ ls
pip-21.1.3  pip-21.1.3.tar.gz  setuptools-57.1.0  setuptools-57.1.0.tar.gz
pi@raspberrypi:~ $ python
Python 3.7.3 (default, Jan 22 2021, 20:04:44)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import lxml
>>>

  没有报错,验证完成。

posted @ 2021-07-13 23:06  逆水寒龙  阅读(750)  评论(1编辑  收藏  举报