0

I have created a mess of Python packages. I have installed some packages with pip and others with apt, and then I have got 3 different versions of Python: python2.7, python3, python3.8. I am now getting errors every now and then that I often spend hours Googling and trying to fix only to find out that it was the packages clashing or something. So, today, I finally decided to nuke everything-python and do a clean install of Python, but since Linux itself depends on Python, I decided to do some Googling to find out the safest way to do that; but I have not found any. There is advice online ranging from "sudo apt purge python" to "DO NOT TOUCH IT", and I was really confused. I want Python to be in the state it was when I first installed Ubuntu. But if there is no safe way of doing that, I will take however much of the junk I can get rid of safely. Also, there is some advice online that package managers like conda are non-intrusive, and if I install one, the packages I install there won't interfere with the ones installed with pip and apt, and life will be happy everafter. How true is this?

Wololo
  • 281
  • 1
  • Which ubuntu/which pip? In my system, pip installs packages into ~/.local/lib/python3.6/site-packages`, so if you cannot remove packages with pip, you can just delete that folder. (I managed to screw up pip in a similar fashion and had to do that). – Ott Toomet Jun 14 '20 at 05:17
  • Conda is somewhat less intrusive and works well as long as you don't need system libraries. The problem with conda is that it install quite a few alternative/updated system libraries that may not work with the other libraries on your computer. But it only matters with compiled packages. – Ott Toomet Jun 14 '20 at 05:19
  • Python 2 isn't installed by default in 18.04 and later. It won't make any difference if you remove it until you don't have any packages which directly depends on Python 2. In the later versions most of the packages depend on Python3.8. Which Ubuntu version are you using? How did you mess up Python? Which Python versions were affected? What is the output of type -a python3 python and file /usr/bin/python3 /usr/bin/python – Kulfy Jun 14 '20 at 05:36
  • @Kulfy I am using 20.04 LTS. As for how I messed up - the packages are somehow conflicting now. Right now, I am unable to get my jupyter notebook running because it is not able to "find" some package. There are fixes for it online, but that is not the solution to the problem and I will keep getting errors like this in the future until this mess I have created is cleaned up – Wololo Jun 14 '20 at 19:43
  • @karel yes! If I understood it right, you don't recommend me (a begineer in Ubuntu) installing Anaconda to manage the packages? – Wololo Jun 14 '20 at 19:46
  • @Kulfy Regarding the question you linked, if I run sudo apt-get install --reinstall pythonX to reinstall pythonX, would that get rid of all the extra packages? By extra I mean the packages I installed. Also, is it safe? – Wololo Jun 14 '20 at 19:50
  • Ananconda makes it easier to manage Python for users of Windows and Mac, harder for Linux users. Even though Anaconda has some nice advanced features, I don't recommend it for new Linux users. – karel Jun 14 '20 at 20:21
  • @karel should I look into virtual environments then? Or just keep on using pip? – Wololo Jun 14 '20 at 20:31
  • @user68186 I would actually prefer not to do that, unless there is no way to fix things otherwise – Wololo Jun 14 '20 at 20:33
  • Python virtual environments have nice security features. – karel Jun 14 '20 at 20:35
  • @karel Thank you! I will look into them – Wololo Jun 14 '20 at 20:46

0 Answers0