Ubuntu16安装pip(升级), numpy, cv2, matplotlib, logging, pillow, scipy, leveldb, lmdb, urllib, python-tk

使用Ubuntu16自带的Python2.7.

1、安装pip:

sudo apt-get install python-pip python-dev

查看pip版本:

pip -V

如果pip版本过高,会导致输入pip -install 后提示

Traceback (most recent call last):
  File "/usr/bin/pip", line 9, in
    from pip import main

ImportError: cannot import name main

修改pip文件:

sudo gedit /usr/bin/pip

将原来的:

  1. from pip import main
  2. if __name__ == '__main__':
  3.     sys.exit(main())

改成:(第一、第三行都要改,建议直接复制粘贴)

  1. from pip import __main__
  2. if __name__ == '__main__':
  3.     sys.exit(__main__._main())

或者将pip降级:

sudo python -m pip install pip==9.0.3

2、安装库

sudo pip install numpy
sudo pip install opencv-python
sudo pip install matplotlib
sudo pip install logging
sudo pip install pillow
sudo pip install scipy

 

 ubuntu16自带的python2.7有urllib2库,测试:

import urllib2

确定没有报错。

 

sudo apt-get install python-tk

 

你可能感兴趣的:(ubuntu,pip)