pip和pip3安装、升级、版本查看及遇到的问题
pip的安装
问题一
sudo apt-get install python-pip #安装pip
sudo pip install --upgrade pip -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com #换成阿里镜像,升级pip
然后查看版本时出现如下错误:
rogn@ubuntu:~$ pip -V
Traceback (most recent call last):
File "/usr/bin/pip", line 9, in <module>
from pip import main
据说原因是:pip 10.0.0及以上版本没有main()
方法一:
考虑降个版本,10.0.0一下就行,例如:
python -m pip install --upgrade pip==9.0.3
以后不要随便升级。
方法二:
这篇博客中说,只需修改 /usr/bin/pip 文件:
这里一定要记得加sudo,也就是以管理员身份打开,否则没有权限修改
from pip import main
if __name__ == '__main__':
sys.exit(main())
改成:
from pip import __main__
if __name__ == '__main__':
sys.exit(__main__._main())
此时查看版本:
rogn@ubuntu:~$ pip -V
/home/rogn/.local/lib/python2.7/site-packages/pip/_vendor/requests/__init__.py:83: RequestsDependencyWarning: Old version of cryptography ([1, 2, 3]) may cause slowdown.
warnings.warn(warning, RequestsDependencyWarning)
pip 19.0.3 from /home/rogn/.local/lib/python2.7/site-packages/pip (python 2.7)
发现已经是19.0.3,问题解决!
问题二
一下是作死过程,请自行忽略
仔细看前面pip -V查看版本时有警告,即:
rogn@ubuntu:~$ pip -V
/home/rogn/.local/lib/python2.7/site-packages/pip/_vendor/requests/__init__.py:83: RequestsDependencyWarning: Old version of cryptography ([1, 2, 3]) may cause slowdown.
warnings.warn(warning, RequestsDependencyWarning)
pip 19.0.3 from /home/rogn/.local/lib/python2.7/site-packages/pip (python 2.7)
这篇博客所说的解决方法:
sudo pip install --upgrade cryptography
sudo python -m easy_install --upgrade pyOpenSSL
然后,没有警告,出现另一个错误:
rogn@ubuntu:~$ pip -V
Traceback (most recent call last):
File "/usr/bin/pip", line 11, in <module>
sys.exit(__main__._main())
AttributeError: 'module' object has no attribute '_main'
根据错误提示我把/usr/bin/pip 文件修改回去:
rogn@ubuntu:~$ sudo vim /usr/bin/pip
rogn@ubuntu:~$ pip -V
pip 8.1.1 from /usr/lib/python2.7/dist-packages (python 2.7)
回到了正常的pip 8.1.1版本,然后奇怪的是,之后怎么也不能升级了:
rogn@ubuntu:~$ sudo pip install --upgrade pip -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
The directory '/home/rogn/.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.
The directory '/home/rogn/.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.
Looking in indexes: http://mirrors.aliyun.com/pypi/simple/
Requirement already up-to-date: pip in /usr/local/lib/python3.5/dist-packages (19.0.3)
就这样吧,反正一般也用的pip3。
pip3的安装
sudo apt-get install python3-pip #安装pip3
sudo pip3 install --upgrade pip -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com #换成阿里镜像,升级pip3
sudo apt-get remove --purge python3-pip #卸载
同样出现前面的问题,只需修改 /usr/bin/pip 文件。
参考链接:
1、https://blog.csdn.net/cangcun2619/article/details/80182284
2、https://blog.csdn.net/weixin_39750084/article/details/81813949
3、https://blog.csdn.net/u013187057/article/details/81360917?utm_source=blogxgwz7
4、https://blog.csdn.net/cow66/article/details/80069309
pip和pip3安装、升级、版本查看及遇到的问题的更多相关文章
- vue-cli的安装及版本查看/更新
vue-cli的安装及版本查看更新 vue-cli安装 npm install vue-cli -g vue-cli的版本查看 vue -V vue-cli的3.0+以后使用的不是vue-cli了,如 ...
- vue-cli的安装及版本查看更新
vue-cli安装 npm install vue-cli -g vue-cli的版本查看 vue -V vue-cli的3.0+以后使用的不是vue-cli了,如果用以上的安装命令安装的并不是最新版 ...
- php5.3 yum安装升级版本到 php5.6
centOS系统下如何将php升级到5.6,之前通过yum来安装lamp环境,直接升级的话,提示没有更新包,也就是说默认情况下php5.3.3是最新 1.查看已经安装的php版本号 键入下面代码: ...
- Python笔记_第五篇_Python数据分析基础教程_相关安装和版本查看
1. IDE说明: 所有的案例用Anacoda中的Jupiter工具进行交互式讲解. 2. 版本和安装: NumPy从如下网站安装:http://sourceforge.net/projects/nu ...
- [Angular] 删除旧版本,升级安装最新版本
目录 删除旧版本 清除未卸载干净的angular-cli缓存 对于Linux 对于Windows 安装最新版本 查看安装版本 创建新项目 删除旧版本 npm uninstall -g angular- ...
- python2.7编译安装升级python3并安装Scrapy
一.安装python3 1.wget https://www.python.org/ftp/python/3.5.1/Python-3.5.1.tgz 2.编译安装,在编译安装前需要构建编译环境,安装 ...
- 多版本python的pip 升级后, pip2 pip3 与python版本失配
mint19.2 本来pip 和 pip2 对应 python2.7 pip3对应python3.6 用源码安装了python3.7之后. 这样 版本也没问题. 但是, 用pip3.7 安装 ...
- pip 查看已安装模块、卸载指定模块、安装指定版本模块
操作背景 最近使用 pandas+numpy+plotly 画heatmap(热力图),来处理股票数据,语法.步骤都没问题,但到画图那一步老是报错,且 plotly 版本为3.1.0: 最后找到原因, ...
- 如何查看pip安装包的所有版本;以及ipython的安装
安装ipython很简单,直接使用pip就行 比如mac环境下:pip install ipython:提示安装失败,原因是pip默认安装的ipython版本6.0+不适用python3.3以下版本 ...
随机推荐
- GridFS大文件的添加、获取、查看、删除
GridFS是一种在MongoDB中存储大二进制文件的机制,使用GridFS的原因有以下几种: 存储巨大的文件,比如视频.高清图片等. 利用GridFS可以简化需求. GridFS会直接利用已经建立的 ...
- jmeter+jenkins+ant部署持续集成测试
原文地址:http://blog.csdn.net/kaluman/article/details/74535495 开头的注意事项: 1.所有的环境变量和代码,都需要使用英文的符号,变量之间都需要英 ...
- C++实现利用(前序和中序生成二叉树)以及(二叉树的镜像)
#include<iostream> #include<string.h> #include<stack> using namespace std; typedef ...
- 数据库几种Top子句的使用方法
转自:https://blog.csdn.net/melody_susan/article/details/47011331
- Hackerearth: Mathison and the Pokémon fights
Mathison and the Pokémon fights code 这是一道比较有意思,出的也非常好的题目. 给定$n$个平面上的点$(x_i, y_i)$,(允许离线地)维护$Q$个操作:1. ...
- Android Service完全解析,关于服务你所需知道的一切(下) (转载)
转自:http://blog.csdn.net/guolin_blog/article/details/9797169 转载请注册出处:http://blog.csdn.net/guolin_blog ...
- 收集一些Unity插件
MCS Male 系列,人形角色插件,表情+体型 Mecanim Control Mecanim Control is a coding tool made that allow for a wide ...
- robotframework自动化系列:文本类型的下拉框
对于下拉框定位和输入,这里主要遇到有两种类型的下拉选择. 其中一个类型是select-options格式,如图 这种方式的定位可以使用select from list by value或select ...
- URAL 1890 . Money out of Thin Air (dfs序hash + 线段树)
题目链接: URAL 1890 . Money out of Thin Air 题目描述: 给出一个公司里面上司和下级的附属关系,还有每一个人的工资,然后有两种询问: 1:employee x y z ...
- Codeforces Round #544 (Div. 3) A.Middle of the Contest
链接:https://codeforces.com/contest/1133/problem/A 题意: 给两个时间点,求中间时间点. 思路: 数学 代码: #include <bits/std ...