Score:0

Age old python install issues, update python3-distils

cn flag

I've had this problem many times and not been able to solve. I've just manually compiled and installed python 3.10 on ubuntu 20.04, for some reason think that latest is likely to be the best however with python this is debatable!

Now when I try to do some updates I get common errors such as these, suggests the system is not finding 'py_compile.py' ?

Setting up python3-distutils (3.8.10-0ubuntu1~20.04) ...
/usr/bin/python3.9: can't open file '/usr/lib/python3.9/py_compile.py': [Errno 2] No such file or directory

However when I search I have many copies of this file in my system including

/usr/local/lib/python3.10/py_compile.py

Where should this file be so the system will find it? Do I need to specify a different install directory for ubuntu, as opposed to most other linux systems, when configuring before the make, make install stages of compiling?

I won't even entertain using purge or anything like that, have removed large parts of the whole system before by doing this, everything seems to be dependent on python! Thx. J

us flag
`/usr/bin/python3.9: can't open file` -- Ubuntu 20.04 has python 3.8. How did you get 3.9 there? Also, did you replace the default python (3.8) with a later version?
Jim Maas avatar
cn flag
I downloaded the 3.9.tar.gz, unzipped it, configure, make, make install but the default install directory appears incorrect for ubuntu? Thx
us flag
That's not a safe way to install python in Ubuntu (unless you know what you are doing). See my answer.
Score:2
sa flag

py_compile.py is provided by libpython3.8-minimal in Ubuntu 20.04. Open the terminal and type:

sudo apt install python3-all libpython3.8-minimal
sudo update-alternatives --config python3 # select python3.8 for auto mode
sudo apt install python3-distutils
sudo apt update
sudo apt upgrade

In addition to the above code, you have broken symbolic links from versions of Python which you deleted, some of which were originally manually installed. These broken symbolic links to deleted versions of Python 3.X are causing apt (which requires python3) to behave improperly. You can find these broken symbolic links by following the instructions in How can I find broken symlinks.

If you find any suspicious looking symbolic links you can scan them with the symlinks package ( sudo apt install symlinks ) and search for any dangling links. dangling links are those for which the target of the link does not currently exist, so dangling links can be safely deleted. If you're unsure about whether a symbolic link can be safely deleted you can rename the link by appending a .bak extension at the end of its name, so that you can quickly restore the link by removing the .bak extension from its name.

Jim Maas avatar
cn flag
Thanks karel, so this would revert back to python 3.8 ... Correct? I think I'm beginning to see that it is not possible to use python 3.9, or 3.10 on Ubuntu 20.04, too much of it was built using 3.8 and installing a new version breaks the system? Is this generally correct?
karel avatar
sa flag
That is correct. Reverting back to python3.8 might solve the package management issue and then you can select python3.9 or python3.10 with `manual mode` Status by running `sudo update-alternatives --config python3` and Press <enter> to keep the current choice[*], or type selection number.
Jim Maas avatar
cn flag
First line works fine, installed both, but the second line doesn't find 3.8, get this "sudo update-alternatives --config python3 There is only one alternative in link group python3 (providing /usr/bin/python3.9): /usr/local/bin/python3.9 Nothing to configure." I can go to the directories in which I compiled 3.9 and 3.10 and do make uninstall but am afraid it will break my whole system? How can I get update-alternatives to find 3.8? It is found if I do update-alternatives --config python (i.e. not python3). Thx. J.
karel avatar
sa flag
Skip the second line for now. Maybe a reboot will let you select 3.8. Continue with the next three commands and check if that solves the issue in your question.
Jim Maas avatar
cn flag
I've done something wrong! "$ python Python 3.10.0 (default, Nov 24 2021, 07:40:12) [GCC 9.3.0] on linux" while "$ which python /usr/bin/python" and "$ /usr/bin/python Python 3.8.10 (default, Sep 28 2021, 16:10:42)" . I must have path statement problems? Too many paths specified?
karel avatar
sa flag
Do you remember how you installed Python 3.10.0? Was it installed from ppa:deadsnakes/ppa? If so, if you can remove ppa:deadsnakes/ppa and run `sudo apt update` you can uninstall Python 3.10.0.
Jim Maas avatar
cn flag
Rather bravely (foolishly!) downloaded the tar.gz, from python.org, unzipped, configured with default settings, make, sudo make install. I just went to that directory and there is no target for sudo make uninstall!
karel avatar
sa flag
Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/131729/discussion-between-karel-and-jim-maas).
Score:1
us flag

The safest way to install python3.10 in Ubuntu 20.04 is to use the deadsnakes PPA.

sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt install python3.10

And then call it with python3.10. For python3.9, install with sudo apt install python3.9.


You have not described what all changes you have done to your system (you seem to have python3.9 and python3.10).

In case you have not removed the default python version (3.8), you can reset the default version with update-alternatives --config python and choose python3.8.

In case you have already replaced the default version with python3.9, you will have to reinstall Ubuntu. The system components in Ubuntu 20.04 are designed to work with python3.8.

Jim Maas avatar
cn flag
Thx for this, so are you suggesting that there is no way to install new versions past 3.8, onto ubuntu 20.04 and not break the whole system? I presume when you say "reinstall Ubuntu" you mean with a newer version, like 21.10?
us flag
Of course you can use python3.9. You simply execute it with `python3.9`. But assign the default version 3.8 to python. You can reinstall whatever version of Ubuntu you want to, but should not mess with the default python version (of course, you can install additional versions, however, the deadsnakes PPA only supports LTS versions of Ubuntu).
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.