ImportError: cannot import name 'main'
See original GitHub issue- Pip version:19.1.1
- Python version: 3.5
- Operating system: Raspberry Pi 3B+
I’ve had issue’s with updating Cryptography, and in the faq, I read that it could be because I’m having an old version of pip. So I’ve updated pip using the next command.
pip install -U pip
After that, i wanted to use pip again and I’m getting the next error:
raceback (most recent call last): File “/usr/bin/pip3”, line 9, in <module> from pip import main ImportError: cannot import name ‘main’
And now pip doesn’t work anymore…
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Error after upgrading pip: cannot import name 'main'
Whenever I am trying to install any package using pip, I am getting this import error: guru@ ...
Read more >[SOLVED] Error after upgrading pip: cannot import name ' ...
This error mostly occurs when you have accidentally upgraded the pip in our system. · It appears when pip and unpack_url are used...
Read more >[Solved] pip Import Error: cannot import name main
Simply speaking, this problem usually occurs when the version upgrade. Solved. First, we need to fix the "pip3" file. sudo vim /usr/bin/pip3.
Read more >ImportError cannot import name main in pip
Hi Guys, I am getting this below error, when I am trying to install numpy in my system. $ pip3 ... import name...
Read more >How to solve ImportError: cannot import name 'main'
When I upgrade pip3 by typing sudo pip3 install -U pip and use the upgraded one, I get an error message ' ImportError:...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It depends on where you got pip from originally. That’s the way to upgrade pip if it’s “your” copy of pip (you installed it yourself, via
get-pip.py
for example, or as part of creating a virtual environment). But if pip was supplied as part of an OS package, then you need to upgrade it according to the rules of that package manager, otherwise you’ve in effect changed files controlled by your package manager without its knowledge, and things can break.The docs could be clearer on this matter - although I’m not sure myself how we do so while keeping things clear and focused on pip (we don’t want to get into trying to explain all of the various package management systems out there and their quirks…) PRs to improve the docs would be welcome 😃
In your case, if your package vendor hasn’t produced a package for the latest version of pip, then you should prompt them to do so, or use a means of having your own copy of pip, for example using a virtualenv. Sorry I can’t offer more suggestions here, I don’t use Linux myself, so my knowledge is limited.
See #5599 - basically you should not be using
pip install -U pip
to upgrade your system pip, as your system pip is managed by your system package manager, and not by pip itself.Specifically,
pip install -U
doesn’t upgrade the/usr/bin/pip3
script, as that’s not something that pip installs, it’s handled by your OS package manager, and now it’s out of sync with your installed pip package.There are a number of suggestions/approaches to diagnosing and fixing your precise issue in #5599 - hopefully one of those should fix your issu.