Skip to content

I broke Python

I was having issues during an upgrade and I deleted the entire /usr/lib/python directory. Yes, I thought "WTF am I doing?" just as I hit enter.

How do I fix this? So much of the system relies on Python. Simply re-installing Python didn't fix it.Can I avoid doing a complete system re-install?

[SOLVED] Thanks to the awesome people on this sub. I installed this system 7 years ago and you've saved it!

Edited 5 Jul 2022. We only hold this version.

143 points19 comments
Open on Reddit
About this post
Posted
Archived
Edited
Score
143 · 94% up
Kind
Text
ID
vrtn69

Author

9
posts
99
comments
3
media
View profile

19 comments

LC_ALL=C pacman -Qk 2>&1 | grep -E ', [1-9][0-9]* missing files' | cut -d':' -f1 should give you a list of packages with missing files, you can pipe that on to pacman by adding | pacman -Syu - to the end

Also to not end here again, what were your "issues upgrading" ? If anything along the lines of "files already exist" that happens if you pip install stuff as root. Do not do that, install your pip stuff as your normal user or better yet into virtual envs if you need it for dev work and keep system locations to system packages.

131 points

should give you a list of packages with missing files, you can pipe that on to pacman by adding

Thanks! I had this problem yesterday and solved it with the command...

pacman -Qqn | grep python | sudo pacman -S -

4 points

Thank you, I had issues updating my system today, so I deleted the site-packages folder, which broke all python stuff. This command fixed it

3 points

pacman -Ql | grep /usr/lib/python | awk '{ print $1 }' | uniq

Reinstall these.

32 points

pacman -Qqo /usr/lib/python* :P

Ah wait we can't rely on the expansion if the dir is missing, shite

but on a properly set up system pacman -Qqo /usr/lib/python{3.10,2.7} should cover the only two logically possible dirs that exist.

14 points

Thanks! You and the others who replied saved a 7 year old installation :)

6 points

What does awk do? Looks like you’re printing something to stdout.

2 points

He's using it to print the first field in each line outputted by grep

2 points

You know what this means, right? Time to take an external backup of your vital directories ;)

-3 points

I don't see a lot of value in backing up system directories that are replaced exactly by packages. I suppose you could take snapshots of the installed package list occasionally if you wanted.

5 points

I normally agree however this is a 7 year old install that OP would clearly be distressed about if it wouldn't boot. So due to the age, I don't see any harm at all in copying their smaller directories onto a USB.

2 points

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.