Forums

I think I just broke pip

I just set up a virtualenv then I deleted it. I deactivated it before deletion. After I deleted it, pip3.* command does not work. All of the files in ~/.local/lib/python3.7/site-packages/bin (including the pip executables) had shebangs that pointed to the python executable in the virtualenv. I deleted that bin folder and tried running pip3 again, but

Nevermind I fixed it

I reinstalled my user installation of pip

I am now too scared to use virtualenv

That sounds either like you somehow set your .local installation as the virtualenv, or you installed something that didn't respect the paths provided by the virtualenv. Another possibility is that you performed a --user install while the virtualenv was activated, so it kind of mixed the virtualenv and .local installs. On reflection, I think the last one seems like the most likely to have caused what you saw.

In pip.conf I have the target option set to my user site-packages directory. Could that be the cause of this problem?

When in venv, pip looks for pip.conf in $VIRTUAL_ENV/pip.conf

See https://pip.pypa.io/en/stable/user_guide/#config-file

Should I switch to using a different things such as pipenv or venv?

Virtualenv is pretty good, I don't think it's more likely to break things than pipenv or venv. I'd recommend using virtualenvwrapper to use it safely, though. To create a virtualenv:

mkvirtualenv myvirtualenv --python=python3.7

That will create a virtualenv using Python 3.7 in the directory /home/dull/.virtualenvs/myvirtualenv, and activate it.

To activate one in a new bash console:

workon myvirtualenv

...and to deactivate whichever one is active:

deactivate

To delete a virtualenv (you need to deactivate first if it's active):

rmvirtualenv myvirtualenv

Actually my pip installation is still broken

I just used the get-pip.py script and I think I fixed it

I should have taken the advice of using virtualenv wrapper that was on the help page about virtualenv