在Ubuntu18.04中安装升级pip3并使用socks代理

本文最后更新于:November 21, 2019 pm

ubuntu18.04中自带了python3但是缺少了pip3,这里我们使用apt来进行安装,然后使用pip3自己对自己升级,再安装对应的socks依赖包,这样在系统使用了socks代理的时候能够使用代理下载各种包,有效提高速度。

1
2
3
4
5
6
7
8
9
10
11
12
13
# 使用apt安装pip3
# 需要注意的是python3-pip和python-pip是不一样的,前者是python3而后者是python2
sudo apt-get install python3-pip

# 使用apt安装的版本很旧,大概是9.0+,我们将它升级到最新
sudo pip3 install --upgrade pip

# 这里顺便附上卸载pip3的命令
sudo apt-get remove python3-pip

# 安装socks所需要的依赖
sudo apt install qt5-qmake qtbase5-dev libqrencode-dev libappindicator-dev libzbar-dev libbotan1.10-dev
sudo pip3 install pysocks

最后我们随便安装一个包来确定一下下载安装的速度

1
2
3
4
5
6
7
8
tinychen@Tiny-Studio:~$ sudo pip3 install numpy
WARNING: The directory '/home/tinychen/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
WARNING: The directory '/home/tinychen/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting numpy
Downloading https://files.pythonhosted.org/packages/d2/ab/43e678759326f728de861edbef34b8e2ad1b1490505f20e0d1f0716c3bf4/numpy-1.17.4-cp36-cp36m-manylinux1_x86_64.whl (20.0MB)
|████████████████████████████████| 20.0MB 4.1MB/s
Installing collected packages: numpy
Successfully installed numpy-1.17.4