Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

Cannot import name main

📅 2018-Aug-03 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ importerror, pip ⬩ 📚 Archive

Problem

I got this error when I tried running pip:

    from pip import main
ImportError: cannot import name 'main'

Solution

I had installed pip from Ubuntu repositories using this command:

$ sudo apt install python-pip

However, I had previously used a pip from Anaconda on this computer. Though I had uninstalled it, it looked like it had left some files that were affecting how the Ubuntu pip worked.

I found the ~/.local/bin and ~/.local/lib directories that Anaconda pip had created and deleted those directories. Ubuntu pip worked fine after that.

Tried with: Ubuntu 16.04