Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pip: main not found - CentOS 7 #5222

Closed
AbdealiLoKo opened this issue Apr 14, 2018 · 7 comments
Closed

pip: main not found - CentOS 7 #5222

AbdealiLoKo opened this issue Apr 14, 2018 · 7 comments
Labels
auto-locked Outdated issues that have been locked by automation

Comments

@AbdealiLoKo
Copy link

  • Pip version: 10.0.0
  • Python version: 2.7.x
  • Operating system: CentOS 7

Description:

When using the latest pip on an existing CentOS 7 we created a virtualenv using the system python and then did a pip install -U pip to get the latest pip version for wheel support and so on.

This has been working for the past few releases.

This gives an error now that the main function is not found in pip. WHen I do a:

import pip
pip.main

It still gives that main function is not found.

On checking the code, it does look like the main has been removed - https://github.com/pypa/pip/blob/4db471fd8f25dd644fb7079b222cb1d54a83a465/src/pip/__init__.py

But this does not seem to have reflected in the pip binary file inside the virtualenv with the upgrade.

@AbdealiLoKo
Copy link
Author

AbdealiLoKo commented Apr 14, 2018

Seems to be very similar to #5221

But here the pip binary is not being created by CentOS - being created by easy_install:

# cat ./venv/bin/pip
#!/repo/venv/bin/python
# EASY-INSTALL-ENTRY-SCRIPT: 'pip==1.4.1','console_scripts','pip'
__requires__ = 'pip==1.4.1'
import re
import sys
from pkg_resources import load_entry_point

if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
    sys.exit(
        load_entry_point('pip==1.4.1', 'console_scripts', 'pip')()
    )

Seems like if I create a new venv it all works fine though ...
I think there was some weird race condition when the release was happening.

@pfmoore
Copy link
Member

pfmoore commented Apr 14, 2018

pip 1.4.1 is very out of date. Modern pip does not use easy_install, and we wouldn't recommend its use. Again, the recommendation is to not upgrade your system packages except using vendor-supplied packages. I'd hope CentOS (Red Hat?) are on top of this, but either way I'm sure they'll have it sorted before they release a supported pip 10 package. In the meantime you can use virtualenvs if you need pip 10.

@AbdealiLoKo
Copy link
Author

This was indeed for a virtualenv , not for the system.

But seems like creating the venv again fixed it

@vincent6767
Copy link

@AbdealiJK Can you elaborate more how do you fix it? I ran the pip3 install awscli --upgrade --user and got this:

Traceback (most recent call last):
File "/usr/bin/pip3", line 9, in
from pip import main
ImportError: cannot import name 'main'

@AbdealiLoKo
Copy link
Author

@vincent6767 seems like you've updated the system pip which is not a good idea.

I had created a new virtualenv with virtualenv venv (for python2) and inside this venv I was able to upgrade pip correctly.

@vincent6767
Copy link

vincent6767 commented Apr 15, 2018

@AbdealiJK Thanks! I'm going to try your solution.

@lock
Copy link

lock bot commented Jun 2, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot added the auto-locked Outdated issues that have been locked by automation label Jun 2, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jun 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation
Projects
None yet
Development

No branches or pull requests

3 participants