Score:0

Accidentally installed python twice

ma flag

Ubuntu (18.0.4) newbie here. I ran

sudo apt install python3.10

in the terminal, only to discover, that python3 was already installed (next to the standard python 2.7). If I now search this most current python3.10 installation via

apt list "python3.*",

I do not find it (only some python3.8 package and older ones). I wanted to keep this installation as clean as possible, but now I do not know where this python installation went. Can I track it and remove it? Do I have multiple versions now? How do I get rid of them?

user535733 avatar
cn flag
The "standard" python swiched from Py2 to Py3 many years ago, so that statement is confusing. Python 3.10 is not in the Ubuntu repositories yet, so it's unclear what you installed and from what source. Review your /var/log/apt logs to see exactly what was installed and what errored.
aq flag
Is there a particular reason you need Python 3.10 vs the 3.6.9 that comes with Ubuntu 18?
Felix avatar
ma flag
No, I was just looking for the newest one. I installed Atom and couldnt run a script using f-strings, because (I guess) the script package from Atom was pointing to python2.7. I however assumed, that python3 is not installed at all ...
aq flag
f-strings was introduced in 3.6, so you should be fine there. You can actually have many versions of python installed and switch between them, but you generally want to keep the default python installations alone, as other Ubuntu libraries depend on those versions.
Felix avatar
ma flag
@rtaft Yes, that is why I assumed that python3 is missing overall. I did not know that it might be unwise to go for the most current version.
aq flag
@Felix For anything installed using `apt` try not to mix and match versions of things outside of what apt has unless you do a bit of research into it. You can trial and error things in a VM too if you think there might be issues. Sometimes the newest app requires newer libraries and it can become a big rabbit hole trying to get things working. It's one reason some people like `snap`.
Felix avatar
ma flag
@rtaft Thanks, good to know!
Score:1
aq flag

Your system should only have one version of python (2.7) and one version of python3 (3.6) installed for Ubuntu 18. If you wish to install additional versions, you can do it outside of apt by manually downloading it and installing it in its own directory.

There are also tools like pyenv that allow you to manage this. It won't affect the other installations or software that depends on those being there. Different versions can be 'activated' in the current terminal or for specific users.

Score:-3
cn flag

Open the terminal and try sudo apt purge -y python2.7-minimal ,change the version to any version you want to uninstall.

then run python --version to see what version you have.

Felix avatar
ma flag
After doing what you recommended, it says: `bash; \usr\bin\python: No such file or directory`
Felix avatar
ma flag
ah, on `python3 --version` I get `Python 3.6.9`!
frippe avatar
ug flag
This is potentially really bad advice. If you happen to purge the system installation, things will break since there's a bunch of stuff depending on it.
aq flag
I'm not sure why this advice was given as this is for Ubuntu 18 and may have caused it to remove required libraries. It is normal for Python 2 and Python 3 to coexist, as they use different commands `python` and `python3`
Felix avatar
ma flag
Oh shoot. What do I do now?
aq flag
reinstall everything that was purged would be my advice.
Felix avatar
ma flag
So just `sudo apt install -y python2.7-minimal` should be good?
aq flag
no, if you still have the terminal open from when it was removed, it should list everything else that it removed...usually anything that depends on python2.7-minimal
ru flag
Yes, however if your stuff still errors then you're facing a reinstall of the entire OS. **You should never be altering system level binaries for Python or Python libraries as the OS you're using is dependent on the python that is available in the repos, and is likely to break your OS if you start moving and removing and altering the versions in use.**
Felix avatar
ma flag
@ThomasWard Thank you. Jeez, guess it's my bad day. I will be more careful with advice on removing stuff on stackexchange ... :( Sadly I closed the terminal inbetween, so I do not know what else was removed.
frippe avatar
ug flag
@Felix, It won't list individual python packages, but you also have `/var/log/apt/history.log`. This log can be useful to figure out what has been installed or removed recently, in case your system has started acting weird all of a sudden or if you weren't really paying attention when running `apt` (or simply using `-y`) etc.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.