ITPub博客

首页 > 应用开发 > IT综合 > 【Python】升级python至2.7后pip不可用

【Python】升级python至2.7后pip不可用

原创 IT综合 作者:小亮520cl 时间:2016-11-10 11:28:48 0 删除 编辑

报错如下:

1
2
3
4
5
# pip
Traceback ( most recent call last ) :
   File "/usr/bin/pip" , line 5 , in < module >
     from pkg_resources import load_entry_point
ImportError : No module named pkg_resources

其实发生这个问题是因为:虽然你已经把Python升级到了2.7版本,但是pip仍然是原来的,版本,仍然在原来python的site-package里面


解决方法:
重新安装pip
复制代码
curl -O https://pypi.python.org/packages/source/p/pip/pip-7.1.2.tar.gz
用wget下载时会报错,这里改用curl -O
tar zxvf pip-7.1.2.tar.gz     
cd pip-7.1.2    
python setup.py install
ln -s /usr/local/python27/bin/pip2.7 /usr/bin/pip  #创建软链接时报文件已经存在时执行rm -rf /usr/bin/pip
//pip默认安装到了/usr/local/python27/bin下面 
复制代码

测试pip

复制代码
[root@localhost pip-7.1.2]# pip list
distribute (0.6.14)
pip (7.1.2)
setuptools (0.6rc11)
wheel (0.29.0)
The directory '/root/.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.
/usr/local/python27/lib/python2.7/site-packages/pip-7.1.2-py2.7.egg/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
You are using pip version 7.1.2, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
复制代码

 

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/29096438/viewspace-2128231/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
毕业以后专业任职数据库工程师职位,itpub一直作为自己的笔记记录的地方,blog写的不详细,草书笔记,仅供参考!

注册时间:2013-09-12

  • 博文量
    529
  • 访问量
    1126938