ImportError: cannot import name main when running pip --version command in windows7 32 bit

后端 未结 16 1420
余生分开走
余生分开走 2020-11-28 01:28

I\'ve installed the latest python (2.7.9) bundled with pip and setuptools for windows 32-bit. I\'ve tried reinstalling pip but the problem persists.

Here\'s the erro

相关标签:
16条回答
  • 2020-11-28 02:00

    In our case, in 2020 using Python3, the solution to this problem was to move the Python installation to the cloud-init startup script which instantiated the VM.

    We had been encountering this same error when we had been trying to install Python using scripts that were called by users later in the VM's life cycle, but moving the same Python installation code to the cloud-init script eliminated this problem.

    0 讨论(0)
  • 2020-11-28 02:03

    On Ubuntu Server 16, I have the same problem with python27. Try this:

    Change

    from pip import main
    if __name__ == '__main__':
        sys.exit(main())
    

    To

    from pip._internal import main
    if __name__ == '__main__':
        sys.exit(main())
    
    0 讨论(0)
  • 2020-11-28 02:04

    On Windows 10, I had the same problem. PIP 19 was already installed in my system but wasn't showing up. The error was No Module Found.

    python -m pip uninstall pip
    python -m pip install pip==9.0.3
    

    Downgrading pip to 9.0.3 worked fine for me.

    0 讨论(0)
  • 2020-11-28 02:05

    The bug is found in pip 10.0.0.

    In linux you need to modify file: /usr/bin/pip from:

    from pip import main
    if __name__ == '__main__':
        sys.exit(main())
    

    to this:

    from pip import __main__
    if __name__ == '__main__':
        sys.exit(__main__._main())
    
    0 讨论(0)
  • 2020-11-28 02:08

    Even though the original question seems to be from 2015, this 'bug' seems to affect users installing pip-10.0.0 as well.

    The workaround is not to modify pip, however to change the way pip is called. Instead of calling /usr/bin/pip call pip via Python itself. For example, instead of the below:

    pip install <package>
    

    If from Python version 2 (or default Python binary is called python) do :

    python -m pip install <package>
    

    or if from Python version 3:

    python3 -m pip install <package> 
    
    0 讨论(0)
  • 2020-11-28 02:09

    On Windows 10, I used the following commands to downgrade pip:

    python -m pip uninstall pip
    python -m pip install pip==9.0.3
    

    This should also work on Linux and Mac too.

    0 讨论(0)
提交回复
热议问题