← All tasks
pythonpypa/pip #5240Not a task: not reproduced

After pip 10 upgrade on pyenv "ImportError: cannot import name 'main'"

envgap__pypa__pip-5240

Original GitHub issue ↗Opened 2018-04-15

01 / FAILURE SIGNATURE

As reported upstream

ImportError: cannot import name 'main'
Not a benchmark task.
  • No curated issue-specific recipe or verified environment fix is available.

02 / ENVIRONMENT RECIPE

Base commit
Not freshly verified
Manifest
requirements.txt
Reproduce
Awaiting issue-specific recipe
Run under trace
Awaiting a meaningful runtime command

03 / ORIGINAL ISSUE TEXT

pypa/pip #5240 · read the original issue
**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.
Continue on GitHub ↗

04 / LABELS

Labels from the report text only; not yet run

No supported category has been assigned.

Label rules and the text that matched
[]

Issue-specific recipe and runtime smoke command require review against the complete issue and repository.

Legacy already_works is install-only; proposed control still requires runtime verification.