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以下版本 ...
随机推荐
- unity3d 公告板
Unity 自带具有一个平面的原始对象,但一个简单的平面在2D游戏或GUI可能是有用的,在任何情况下作出一个好的开始例子.一个最小的平面包含四个顶点,界定两个三角形的边角. 第一件事就是设置顶点数组. ...
- http查看工具
View HTTP Request and Response Header Web-Sniffer Desktop App Please check our new free Web-Sniffer ...
- this关键字使用
原文地址:https://www.cnblogs.com/alsf/p/5515996.html 一,表示类中属性 1,没有使用this的情况 class Person{ // 定义Person类 p ...
- 架构:template
ylbtech-架构: 1.返回顶部 2.返回顶部 3.返回顶部 4.返回顶部 5.返回顶部 6.返回顶部 作者:ylbtech出处:http://ylbtech.cnbl ...
- juju入门
https://jujucharms.com/docs/1.25/config-LXC Installation(Ubuntu) #sudo add-apt-repository ppa:juju/s ...
- JAVA基础--数组的应用04
一.数组的简单应用 1. 数组平均值 例子:求下列数字的平均值:1.0,2.4,3.5,4.3,5.1,6.8,7.2,8,9,10 package cn.haile.array; /** * 练习数 ...
- postman接口测试系列: 时间戳和加密
在使用postman进行接口测试的时候,对于有些接口字段需要时间戳加密,这个时候我们就遇到2个问题,其一是接口中的时间戳如何得到?其二就是对于现在常用的md5加密操作如何在postman中使用代码实现 ...
- easyUI Uncaught TypeError: Cannot read property 'length' of undefined
dataGrid json 封装数据格式为 List<Object> 格式
- AtCoder Grand Contest 001 D - Arrays and Palindrome
题目传送门:https://agc001.contest.atcoder.jp/tasks/agc001_d 题目大意: 现要求你构造两个序列\(a,b\),满足: \(a\)序列中数字总和为\(N\ ...
- forward和sendRedirect的区别
部分内容转自:http://blog.csdn.net/zhouysh/article/details/380364和http://blog.csdn.net/frank_jay/article/de ...