系统中同时存在python2.7, python3.5, python3.6多个版本的Python,,而pip install安装时需要指定安装在某个Python下,,方法如下:

1
2
3
4
5
sudo python3.5 -m pip install openpyxl

sudo python2.7 -m pip install openpyxl

sudo python3.6 -m pip install openpyxl

还有一个问题是pip升级到10后,报错:“ImportError: cannot import name ‘main’”

解决方法:

sudo gedit /usr/bin/pip

将其中内容改为:

1
2
3
4
5
6
7
8
import sys

# Run the main entry point, similarly to how setuptools does it, but because
# we didn't install the actual entry point from setup.py, don't use the
# pkg_resources API.
from pip import __main__
if __name__ == '__main__':
sys.exit(__main__._main())

保存退出