3

Situation:

Whilst using Pycharm on a python3 project, I came across the option under the "Project Interpreter" settings to install a package manager. I clicked it absentmindedly and immediately realized that I had wrought a horror upon myself.

I'm assuming that the option I clicked was to install PIP for python3, because from my terminal I was unable to use PIP correctly. Doing anything with the pip command results with this output:

$ pip install lxml
Traceback (most recent call last):
  File "/usr/local/bin/pip", line 9, in <module>
    load_entry_point('pip==1.5.6', 'console_scripts', 'pip')()
  File "/usr/local/lib/python3.4/dist-packages/setuptools-5.7-py3.4.egg/pkg_resources.py", line 356, in load_entry_point

  File "/usr/local/lib/python3.4/dist-packages/setuptools-5.7-py3.4.egg/pkg_resources.py", line 2472, in load_entry_point
    try:
  File "/usr/local/lib/python3.4/dist-packages/setuptools-5.7-py3.4.egg/pkg_resources.py", line 2186, in load
    self.py_version = py_version
ImportError: No module named 'pip'

I thought PIP was missing, so I tried to remove and re-add the ubuntu package python-pip, I attempted to run python get-pip.py but that reported that PIP was already installed.

After a while, I found that PIP was still installed for python27, but not for python34. (From my understanding) This is what /should/ be expected to prevent the exact issues I'm having now, however, whatever Pycharm did seems to have changed the default behavior in my terminal to look for PIP in python34, despite the fact that my default python is still python27 (verified by running python --version).

I reinstalled PIP for python34 which has given me the ability to install packages again, but I do not want this behavior.

Question:

How do I reset everything so I can safely uninstall PIP for python34 and revert the default PIP to be the python27 version?

(After I've cleaned everything up, I'll start working with virtualenv. I was only made of its existence today while attempting to troubleshoot this issue.)

2 Answers 2

2

When switching python interpreter from 2.7 to 3.4 on pycharm it installed setuptools-5.7 which probably broke my pip. I fixed this by renaming the setuptools files and installing python3 pip. My pip now works again.

cd /usr/local/lib/python3.4/dist-packages sudo mv setuptools-5.7-py3.4.egg setuptools-5.7-py3.4.egg.moved sudo mv setuptools-5.7-py3.4.egg setuptools-5.7-py3.4.egg.moved sudo apt-get install python3-pip

1

Solution

After googling for answers since yesterday, I came across no way to set the default pip. I decided to go through and remove every instance of pip I could discover.

sudo -H pip3 uninstall pip
sudo -H pip2 uninstall pip
sudo apt-get purge -y python-pip
# It should be noted, 'python-pip' is the ubuntu package for pip2, but
# there is also another ubuntu package for pip3. I didn't have it, but you may.

After this I reinstalled pip via sudo -H python get-pip.py, and all seems to be right again. pip3 fails because it is not installed, pip2 confirms the correct pip was installed, and (best of all) just running pip works just like it should.

Learn from me. Use virtualenv and virtualenvwrapper.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .