码迷,mamicode.com
首页 > 其他好文 > 详细

centos自定义安装pip3

时间:2018-09-30 20:05:26      阅读:183      评论:0      收藏:0      [点我收藏+]

标签:from   default   src   python3.7   中间   usr   process   efault   tmp   



题记

在之前的文章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再安装。我没有急于执行而是去看了下 官方文档
其中有这样的表述:

技术分享图片


大概意思是:

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

标签:from   default   src   python3.7   中间   usr   process   efault   tmp   

原文地址:https://www.cnblogs.com/tig666666/p/9733009.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!