{"action":"created","issue":{"url":"https://api.github.com/repos/pypa/pip/issues/5240","repository_url":"https://api.github.com/repos/pypa/pip","labels_url":"https://api.github.com/repos/pypa/pip/issues/5240/labels{/name}","comments_url":"https://api.github.com/repos/pypa/pip/issues/5240/comments","events_url":"https://api.github.com/repos/pypa/pip/issues/5240/events","html_url":"https://github.com/pypa/pip/issues/5240","id":314425497,"number":5240,"title":"After pip 10 upgrade on pyenv \"ImportError: cannot import name 'main'\"","user":{"login":"KleinerNull","id":13742580,"avatar_url":"https://avatars0.githubusercontent.com/u/13742580?v=4","gravatar_id":"","url":"https://api.github.com/users/KleinerNull","html_url":"https://github.com/KleinerNull","followers_url":"https://api.github.com/users/KleinerNull/followers","following_url":"https://api.github.com/users/KleinerNull/following{/other_user}","gists_url":"https://api.github.com/users/KleinerNull/gists{/gist_id}","starred_url":"https://api.github.com/users/KleinerNull/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KleinerNull/subscriptions","organizations_url":"https://api.github.com/users/KleinerNull/orgs","repos_url":"https://api.github.com/users/KleinerNull/repos","events_url":"https://api.github.com/users/KleinerNull/events{/privacy}","received_events_url":"https://api.github.com/users/KleinerNull/received_events","type":"User","site_admin":false},"labels":[{"id":634456269,"url":"https://api.github.com/repos/pypa/pip/labels/kind%20-%20invalid","name":"kind - invalid","color":"cccccc","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":37,"created_at":"2018-04-15T15:31:49Z","updated_at":"2018-04-18T16:28:35Z","closed_at":"2018-04-17T13:31:42Z","author_association":"NONE","body":"* Pip version: 10.0\r\n* Python version: 3.6.2\r\n* Operating system: Ubuntu 16.04\r\n\r\n### Description:\r\nAfter 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:\r\n\r\n    Traceback (most recent call last):\r\n      File \"/home/kleinernull/.pyenv/versions/3.6.2/bin/pip\", line 7, in <module>\r\n        from pip import main\r\n    ImportError: cannot import name 'main'\r\n    Traceback (most recent call last):\r\n      File \"/home/kleinernull/.pyenv/versions/3.6.2/bin/pip\", line 7, in <module>\r\n        from pip import main\r\n    ImportError: cannot import name 'main'\r\n\r\nThe content of all three different pip files is the same:\r\n\r\n    ~ ⟩ cat .pyenv/versions/3.6.2/bin/pip                                                                            ~\r\n    #!/home/kleinernull/.pyenv/versions/3.6.2/bin/python3.6\r\n\r\n    # -*- coding: utf-8 -*-\r\n    import re\r\n    import sys\r\n\r\n    from pip._internal import main as _main\r\n\r\n    if __name__ == '__main__':\r\n        sys.argv[0] = re.sub(r'(-script\\.pyw?|\\.exe)?$', '', sys.argv[0])\r\n        sys.exit(_main())\r\n\r\n    ~ ⟩ cat .pyenv/versions/3.6.2/bin/pip3                                                                           ~\r\n    #!/home/kleinernull/.pyenv/versions/3.6.2/bin/python3.6\r\n\r\n\r\n    # -*- coding: utf-8 -*-\r\n    import re\r\n    import sys\r\n\r\n    from pip import main\r\n\r\n    if __name__ == '__main__':\r\n        sys.argv[0] = re.sub(r'(-script\\.pyw?|\\.exe)?$', '', sys.argv[0])\r\n        sys.exit(main())\r\n\r\n    ~ ⟩ cat .pyenv/versions/3.6.2/bin/pip3.6                                                                         ~\r\n    #!/home/kleinernull/.pyenv/versions/3.6.2/bin/python3.6\r\n\r\n    # -*- coding: utf-8 -*-\r\n    import re\r\n    import sys\r\n\r\n    from pip import main\r\n\r\n    if __name__ == '__main__':\r\n        sys.argv[0] = re.sub(r'(-script\\.pyw?|\\.exe)?$', '', sys.argv[0])\r\n        sys.exit(main())\r\n\r\nThe same happend with my 3.6.1 environment too.\r\n\r\n### Temporaly fix\r\nAccording to the code of the master branch the import should be that:\r\n\r\n    #!/home/kleinernull/.pyenv/versions/3.6.2/bin/python3.6\r\n\r\n    # -*- coding: utf-8 -*-\r\n    import re\r\n    import sys\r\n\r\n    from pip._internal import main as _main\r\n\r\n    if __name__ == '__main__':\r\n        sys.argv[0] = re.sub(r'(-script\\.pyw?|\\.exe)?$', '', sys.argv[0])\r\n        sys.exit(_main())\r\n\r\nAnd this resolves the issue. I have no clue if this has something to do with the upgrade itself or with pyenv as environment."},"comment":{"url":"https://api.github.com/repos/pypa/pip/issues/comments/382447577","html_url":"https://github.com/pypa/pip/issues/5240#issuecomment-382447577","issue_url":"https://api.github.com/repos/pypa/pip/issues/5240","id":382447577,"user":{"login":"guidion","id":7102062,"avatar_url":"https://avatars2.githubusercontent.com/u/7102062?v=4","gravatar_id":"","url":"https://api.github.com/users/guidion","html_url":"https://github.com/guidion","followers_url":"https://api.github.com/users/guidion/followers","following_url":"https://api.github.com/users/guidion/following{/other_user}","gists_url":"https://api.github.com/users/guidion/gists{/gist_id}","starred_url":"https://api.github.com/users/guidion/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guidion/subscriptions","organizations_url":"https://api.github.com/users/guidion/orgs","repos_url":"https://api.github.com/users/guidion/repos","events_url":"https://api.github.com/users/guidion/events{/privacy}","received_events_url":"https://api.github.com/users/guidion/received_events","type":"User","site_admin":false},"created_at":"2018-04-18T16:28:35Z","updated_at":"2018-04-18T16:28:35Z","author_association":"NONE","body":"**I fixed this way:**\r\n\r\n$ pip --version\r\nTraceback (most recent call last):\r\n  File \"/usr/bin/pip\", line 9, in <module>\r\n    from pip import main\r\nImportError: cannot import name main\r\n$ sudo apt-get remove python-pip\r\n$ sudo apt-get install python-pip\r\n$ pip --version\r\npip 10.0.0 from /home/user/.local/lib/python2.7/site-packages/pip (python 2.7)\r\n\r\n**I hope that helps someone.**"}}
{"actor":{"display_login":"guidion"}}