Ubuntu安装了Python2和Python3,无法定位pip3

环境

Ubuntu 14.06

安装python2,版本为Python 2.7.12

安装python3,版本为Python 3.5.2

问题描述

由于使用python3需要beautifulsoup4和lxml模块。

使用

pip install beautifulsoup
pip install lxml

结果都安装到了python2中,没有正确安装到python3上。马上使用pip3

$sudo pip3 install beautifulsoup 
zsh: command not found: pip3

告诉我们没有pip3。使用apt安装pip3,反馈如下

$ sudo apt-get install python3-pip
Reading package lists... Done
Building dependency tree       
Reading state information... Done
python3-pip is already the newest version (8.1.1-2ubuntu0.4).

什么情况,pip3已经安装了。但是就是定位不到pip3。

问题分析

由于共存了pytho2和python3导致。

解决方法

使用sudo python3 -m pip install --upgrade pip。

$sudo python3 -m pip install --upgrade pip
Collecting pip
  Downloading http://mirrors.cloud.aliyuncs.com/pypi/packages/54/0c/d01aa759fdc501a58f431eb594a17495f15b88da142ce14b5845662c13f3/pip-20.0.2-py2.py3-none-any.whl (1.4MB)
    100% |████████████████████████████████| 1.4MB 43.9MB/s 
Installing collected packages: pip
  Found existing installation: pip 8.1.1
    Not uninstalling pip at /usr/lib/python3/dist-packages, outside environment /usr
Successfully installed pip-20.0.2

安装完成后,使用pip3 -v来验证是否安装成功。安装成功如下所示:

pip3 -v

Usage:   
  pip3 <command> [options]

使用sudo pip3 install beautifulsoup4,安装beautifulsoup4模块,如下所示:

 sudo pip3 install beautifulsoup4       
Looking in indexes: http://mirrors.cloud.aliyuncs.com/pypi/simple/
Collecting beautifulsoup4
  Downloading http://mirrors.cloud.aliyuncs.com/pypi/packages/cb/a1/c698cf319e9cfed6b17376281bd0efc6bfc8465698f54170ef60a485ab5d/beautifulsoup4-4.8.2-py3-none-any.whl (106 kB)
     |████████████████████████████████| 106 kB 16.2 MB/s 
Collecting soupsieve>=1.2
  Downloading http://mirrors.cloud.aliyuncs.com/pypi/packages/81/94/03c0f04471fc245d08d0a99f7946ac228ca98da4fa75796c507f61e688c2/soupsieve-1.9.5-py2.py3-none-any.whl (33 kB)
Installing collected packages: soupsieve, beautifulsoup4
Successfully installed beautifulsoup4-4.8.2 soupsieve-1.9.5

使用sudo pip3 install lxml,安装lxml模块,如下所示:

 sudo pip3 install lxml          
Looking in indexes: http://mirrors.cloud.aliyuncs.com/pypi/simple/
Collecting lxml
  Downloading http://mirrors.cloud.aliyuncs.com/pypi/packages/f2/e5/304cfec4e0abebb4a4e16f56129df792c81f1bcdbb1432d1a63f749f8b74/lxml-4.5.0-cp35-cp35m-manylinux1_x86_64.whl (5.7 MB)
     |████████████████████████████████| 5.7 MB 901 kB/s 
Installing collected packages: lxml
Successfully installed lxml-4.5.0

这样大功告成。

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

努力的老周

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值