From a9e50293dceb237d665ba56903d414f5302ca4ff Mon Sep 17 00:00:00 2001 From: Yaroslav Date: Tue, 17 Mar 2020 15:19:15 +0300 Subject: started migration of weblog articles --- .../index.md | 59 ++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 content/weblog/2018-08-03_how-to-break-and-repair-pip/index.md (limited to 'content/weblog/2018-08-03_how-to-break-and-repair-pip/index.md') diff --git a/content/weblog/2018-08-03_how-to-break-and-repair-pip/index.md b/content/weblog/2018-08-03_how-to-break-and-repair-pip/index.md new file mode 100644 index 0000000..c2aa000 --- /dev/null +++ b/content/weblog/2018-08-03_how-to-break-and-repair-pip/index.md @@ -0,0 +1,59 @@ ++++ +title = "How to break pip, and how to repair it..." +date = 2018-08-03T22:00:00Z ++++ + +Sometimes a program may suggest to you something, and you may following said +program's suggestion, because, why not, you trust the devs because they've done +an amazing job developing the program, and heck, they should know what they are +doing with their tools. + + + +With pip, this does not seem to be the case however. I've come across this +issue on my laptop and desktop computers running Manjaro, and while fixed it on +my laptop, I forgot how to fix it by the time I encountered on my desktop. The +problem: pip refuses to collect a package while trying to install any package +system wide (e.g. pywal), exiting with an exception like 'ModuleNotFoundError' +or something similar. + +First, I'll write down what NOT to do to avoid getting this error. + +You may get a message like this when after installing a package with pip + +```sh +You are using pip version x.x.x, however version x.x is available. +You should consider upgrading via the 'pip install --upgrade pip' command. +``` + +If you get the following while NOT using a virtual environment, don't pay +attention to it. Don't even look at it. Just ignore it. I didn't, and now I am +writing a post about how to fix the mess that it causes because of following +that seemingly innocent and well-intended advice. At least not if you are using +an Arch-based distribution, don't really know about how this is managed in +other distributions, since I don't recall having this problem when using +Debian. + +Now, if you are using a virtual environment, you obviously can and should +upgrade pip this way. However, system-wide, your package manager (pacman) +should take care of upgrading pip along with your other packages when you +upgrade your system (pacman -Syu). + +## The fix + +If you unfortunately, like me, already ran the upgrade through pip, you should +first delete some files, by running this command: + +```sh +$ sudo rm -rf /usr/lib/python3.6/site-packages/pip /usr/lib/python3.6/site-packages/pkg_resources +``` + +Then, you should reinstall pip and setup tools: + +```sh +$ sudo pacman -S python-setuptools python-pip +``` + +And that's it! Your pip should now be as good as new. + +I found the solution in this forum thread: [https://bbs.archlinux.org/viewtopic.php?id=237451](https://bbs.archlinux.org/viewtopic.php?id=237451) -- cgit v1.2.3