How To Install Python-distutils For Old Python Versions
Solution 1:
What about things like deadsnakes or pyenv, would those help? Otherwise you might need to add the apt repositories for older Ubuntu versions (say 18.04), but I am not sure what the side effects might be. This is a question that I would rather ask on Ask Ubuntu or Super User.
Solution 2:
(from bounty description)
I want a definitive solution that does NOT involve someone telling me to install:
- python-distutils
- python3-distutils
- python3-distutils-extra
I will be handing out FREE DOWNVOTES to anyone who mentions installing these.
Well, I have some bad news for you. There is no "official" way to get distutils
on the Debian-provided python*
packages without installing these packages, not unless you go outside of Debian's default package repositories.
This is a consequence of Debian's decision to break up various parts of Python's standard library into separate packages, on the basis of their policy to split things into runtime packages and development packages. They consider distutils to fall in the "development" part, and thus, don't distribute it as part of the standard python
package.
Basically, your options are:
- install a
python*-distutils
package.- This is what your OS maintainers recommend doing in your situation.
- You've not explained why you'll "be handing out free downvotes" for anyone recommending this, but this is genuinely the "most correct" solution.
- install Python, from somewhere that does not break up the standard library.
- This would mean using a package source other than the official debian repositories.
- The easiest source would be the deadsnakes ppa.
- compile your own Python!
- This isn't actually that difficult, and tools like pyenv make it easy to compile and manage multiple python versions.
- hack around the problem!
- You could... download the sources from CPython's repo, and place the
Lib/distutils
folder somewhere on the import path forpythonX.Y
? This is a 100% hack though and I strongly recommend not doing this. If something bad happens, because you did this, I'm not responsible.
- You could... download the sources from CPython's repo, and place the
Solution 3:
I've been looking for an answer to this question for almost as long as you, and finally found a solution.
Be warned, I may have screwed up my python3.8 installation as a side-effect, and it's possible the package will be uninstalled again and break things as soon as you run apt-update.
Also, it may be possible to reduce the number of commands, but here's what I ended up doing:
Run apt list
to see a list of available packages:
$ apt list -a python3-distutils
Listing... Done
python3-distutils/focal-updates,focal-updates,focal-security,focal-security,now 3.8.5-1~20.04.1 all [installed]
python3-distutils/focal,focal 3.8.2-1ubuntu1 all
python3-distutils/bionic-updates,bionic-updates 3.6.9-1~18.04 all
python3-distutils/bionic,bionic 3.6.5-3 all
Then download the "bionic" deb package,
because it actually contains multiple versions of distutils
,
for Pythons 3.6, 3.7 & 3.8:
$ apt download python3-distutils/bionic
Get:1 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 python3-distutils all 3.6.9-1~18.04 [144 kB]
Fetched 144 kB in 0s (661 kB/s)
Finally, install the deb package:
$ sudo dpkg --install python3-distutils_3.6.9-1~18.04_all.deb
dpkg: warning: downgrading python3-distutils from3.8.5-1~20.04.1 to 3.6.9-1~18.04
(Reading database ... 193375 files and directories currently installed.)
Preparing to unpack python3-distutils_3.6.9-1~18.04_all.deb ...
Unpacking python3-distutils (3.6.9-1~18.04) over (3.8.5-1~20.04.1) ...
Setting up python3-distutils (3.6.9-1~18.04) ...
At this point, I was finally able to use pip with python3.6.
Note-1: The printouts of
apt list -a
above depend on whether you run an Ubuntu or a Debian distribution, and which apt-repos you have activated in /etc/apt/sources.list*.
Note-2: As seen in the case of
python3-distutils/bionic
, above, the name of the package does not always coincide with its contents. To view them, you have to download it and inspect it withdpkg -C <pafkage-file>
, or from remote withapt-file list python3-distutils
.
Note-3: In case you cannot find the exact
distutils
version for a specific Python release, you may install an earlier version and symlink to it. For example in Debian-unstable("sid") and "bullseye" as of January 2020, thepython3-distutils
package contained in their apt-repos has files just for Python3.9, and the previous apt-repos from "buster" contain files for Python3.7 only. So if you wish to installdistutils
for Python3.8, you have to download the "buster" package and execute:
$ sudo dpkg --unpack python3-distutils_3.7.3-1_all.deb$ sudo rm /usr/lib/python3.8/distutils/distutils/$ sudo ln -w /usr/lib/python3.{7,8}/distutils/distutils/
Solution 4:
1) Run update command to update package repositories and get latest package information
sudo apt-getupdate-y
2) Run the install command with -y flag to quickly install the packages and dependencies.
sudo apt-get install -y python-distutils-extra
or
go to this site, there is more details. https://ubuntu.pkgs.org/18.04/ubuntu-universe-amd64/python-distutils-extra_2.41ubuntu1_all.deb.html
Post a Comment for "How To Install Python-distutils For Old Python Versions"