Search this site

Friday, April 19, 2019

pip error main(?)

I just upgrade my pip in raspdebian and I got this error when I run pip

Error message

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

I already tried to reinstall pip from apt but it didn't solve the problem

In the end, I found something

type in terminal
nano  /usr/bin/pip
that will open pip file like this
import sys
from pip import main
if __name__ == '__main__':
     sys.exit(main())

1. Change "from pip import main" to "from pip import __main__"
2. Change "sys.exit(main())" to "sys.exit(__main__._main())"

The result is like this
import sys
from pip import __main__
if __name__ == '__main__':
     sys.exit(__main__._main())
exit nano and save

and you can use your pip again