Closed
Description
Maintainer note: Anyone that still gets this issue please see #5599.
- Pip version: 10.0
- Python version: 3.6.2
- Operating system: Ubuntu 16.04
Description:
After upgrading pip from 9.03 to 10.0 via pip install pip --user --upgrade
in a pyenv environment pip refueses to start and raise this instead:
Traceback (most recent call last):
File "/home/kleinernull/.pyenv/versions/3.6.2/bin/pip", line 7, in <module>
from pip import main
ImportError: cannot import name 'main'
Traceback (most recent call last):
File "/home/kleinernull/.pyenv/versions/3.6.2/bin/pip", line 7, in <module>
from pip import main
ImportError: cannot import name 'main'
The content of all three different pip files is the same:
~ ⟩ cat .pyenv/versions/3.6.2/bin/pip ~
#!/home/kleinernull/.pyenv/versions/3.6.2/bin/python3.6
# -*- coding: utf-8 -*-
import re
import sys
from pip._internal import main as _main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.exit(_main())
~ ⟩ cat .pyenv/versions/3.6.2/bin/pip3 ~
#!/home/kleinernull/.pyenv/versions/3.6.2/bin/python3.6
# -*- 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())
~ ⟩ cat .pyenv/versions/3.6.2/bin/pip3.6 ~
#!/home/kleinernull/.pyenv/versions/3.6.2/bin/python3.6
# -*- 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())
The same happend with my 3.6.1 environment too.
Temporaly fix
According to the code of the master branch the import should be that:
#!/home/kleinernull/.pyenv/versions/3.6.2/bin/python3.6
# -*- coding: utf-8 -*-
import re
import sys
from pip._internal import main as _main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.exit(_main())
And this resolves the issue. I have no clue if this has something to do with the upgrade itself or with pyenv as environment.