Upgrade Error pip effective solutions ImportError: can not import name 'main'

Upgrade Error pip effective solutions ImportError: can not import name 'main'

This problem is usually a pip from 9.xx version upgrade to a higher cause, mainly because there are modified but not updated after the upgrade file pip pip API function. The method as described hereafter change pip file.


According to the code hints file path editing error pip

For example, my path is / usr / bin / pip (pip2 and pip3 corresponding path is pip2, pip3)

sudo gedit /usr/bin/pip

File open as follows

#!/usr/bin/python3
# GENERATED BY DEBIAN

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())
    

Modify the code the third line and the last line:

#!/usr/bin/python3
# GENERATED BY DEBIAN

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._internal import main
if __name__ == '__main__':
    sys.exit(main.main())
    

Run directly after saving

pip --version

That success without error

Problem solving, leave a praise it ~

K .
Released six original articles · won praise 6 · views 5708

Guess you like

Origin blog.csdn.net/czksnk/article/details/104040509