centos自定义安装pip3

题记

在之前的文章centos云服务器安装Python3记录 记录了怎么自定义安装 Python3 ,在后边测试pip3的时候发现了个问题:

pip --version

terminal 打印:

pip 8.1.2 from /usr/lib/python2.7/site-packages (python 2.7)

如上:pip版本还是 Python2.7 版本

解决

由于对于系统和Python并不是特别熟悉,首先想到的是问下度娘。度娘给了几种建议全部是下载pip再安装。我没有急于执行而是去看了下 官方文档

其中有这样的表述:

centos自定义安装pip3

大概意思是:

1.看下系统内pip是否可用:

[root@liuyonghu python3]# pip --version
pip 8.1.2 from /usr/lib/python2.7/site-packages (python 2.7)

2.查看pip是否存在于安装包

[root@liuyonghu python3]# python -m ensurepip --default-pip

Looking in links: /tmp/tmpzzl1ppca

Requirement already satisfied: setuptools in ./lib/python3.7/site-packages (39.0.1)

Requirement already satisfied: pip in ./lib/python3.7/site-packages (10.0.1)

3. 由步骤 2 可知,pip3已经存在于 Python3.7 的安装文件中,只是没有对应的软链

[root@liuyonghu bin]# ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3

[root@liuyonghu bin]# pip3 --version
pip 10.0.1 from /usr/local/python3/lib/python3.7/site-packages/pip (python 3.7)

4.想起来自己mac上的pip还是用的pip3,于是也修改软链。

Last login: Sat Sep 29 23:13:21 on ttys002
liuyonghudeMacBook-Pro:~ liuyonghu$ pip3 --version
pip 9.0.1 from /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (python 3.6) liuyonghudeMacBook-Pro:~ liuyonghu$ which python3
/usr/local/bin/python3 liuyonghudeMacBook-Pro:~ liuyonghu$ which pip3 /usr/local/bin/pip3 liuyonghudeMacBook-Pro:~ liuyonghu$ ln -s /Library/Frameworks/Python.framework/Versions/3.6/bin/pip3 /usr/local/bin/pip liuyonghudeMacBook-Pro:~ liuyonghu$ pip --version pip 9.0.1 from /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (python 3.6)

5. 其实中间查找pip路径的步骤比较费劲,也记录下来。

[root@liuyonghu python3]# pip --version
pip 8.1.2 from /usr/lib/python2.7/site-packages (python 2.7)
[root@liuyonghu python3]# python -m ensurepip --default-pip
Looking in links: /tmp/tmpzzl1ppca
Requirement already satisfied: setuptools in ./lib/python3.7/site-packages (39.0.1)
Requirement already satisfied: pip in ./lib/python3.7/site-packages (10.0.1)
[root@liuyonghu python3]# cd /user/bin
-bash: cd: /user/bin: 没有那个文件或目录
[root@liuyonghu python3]# cd /usr/bin
[root@liuyonghu bin]# ls pip*
pip pip2 pip2.7
[root@liuyonghu bin]# mv pip pip.bak
[root@liuyonghu bin]# cd ./lib/python3.7/site-packages (10.0.1)
-bash: 未预期的符号 `(' 附近有语法错误
[root@liuyonghu bin]# cd usr/lib/python3.7/site-packages (10.0.1)
-bash: 未预期的符号 `(' 附近有语法错误
[root@liuyonghu bin]# cd usr/lib/python3.7/site-packages
-bash: cd: usr/lib/python3.7/site-packages: 没有那个文件或目录
[root@liuyonghu bin]# mv pip.bak pip
[root@liuyonghu bin]# ls pip*
pip pip2 pip2.7
[root@liuyonghu bin]# cd usr/lib/python3.7
-bash: cd: usr/lib/python3.7: 没有那个文件或目录
[root@liuyonghu bin]# cd usr/local/python3
-bash: cd: usr/local/python3: 没有那个文件或目录
[root@liuyonghu bin]# cd /usr/lib/python3.7
-bash: cd: /usr/lib/python3.7: 没有那个文件或目录
[root@liuyonghu bin]# cd /usr/local
[root@liuyonghu local]# cd python3
[root@liuyonghu python3]# ls pip*
ls: 无法访问pip*: 没有那个文件或目录
[root@liuyonghu python3]# ls
bin include lib share
[root@liuyonghu python3]# cd lib
[root@liuyonghu lib]# cd lib
-bash: cd: lib: 没有那个文件或目录
[root@liuyonghu lib]# ls pip*
ls: 无法访问pip*: 没有那个文件或目录
[root@liuyonghu lib]# cd ..
[root@liuyonghu python3]# cd bin
[root@liuyonghu bin]# ls pip*
pip3 pip3.7
[root@liuyonghu bin]# ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
[root@liuyonghu bin]# pip3 --version
pip 10.0.1 from /usr/local/python3/lib/python3.7/site-packages/pip (python 3.7)

总结:

1.Python3 在解压,在预定目录,编译安装之后,生成了Python、pip的执行文件。

2.在系统中的指令存在于不同系统的 /usr/*/bin/ 文件夹中,如有需要可以自己去建立软链。

centos自定义安装pip3

亲情链接:

简书

博客园

上一篇:APP的CPU,内存,耗电,流量测试工具


下一篇:mysql分页(ajax)