ImportError: cannot import name main
python
修改前linux
# -*- coding: utf-8 -*- import re import sys from pip import main if __name__ == '__main__': sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0]) sys.exit(main())
修改後spa
import re import sys from pip import __main__ if __name__ == '__main__': sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0]) sys.exit(__main__._main())
而後查看pip版本
pip -V
pip 18.1 from /usr/local/lib/python3.6/site-packages/pip (python 3.6)
這時沒有報錯,完成修改code