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

后端 未结 16 1521
余生分开走
余生分开走 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 01:57

    It works on ubuntu 16.04. Step 1:

     sudo gedit /home/user_name/.local/bin/pip
    

    a file opens with the content:

    #!/usr/bin/python
    
    # -*- 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())
    

    Change the main to __main__ as it appears below:

    #!/usr/bin/python
    
    # -*- 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__._main())
    

    Save the file and close it. And you are done!

提交回复
热议问题