When I try to run pip3, I get:
$ pip3
Traceback (most recent call last):
File "/usr/bin/pip3", line 5, in <module>
from pip._internal.cli.main import main
File "/mnt/afids/install/lib/python3.8/site-packages/pip/_internal/cli/main.py", line 10, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "/mnt/afids/install/lib/python3.8/site-packages/pip/_internal/cli/autocompletion.py", line 9, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "/mnt/afids/install/lib/python3.8/site-packages/pip/_internal/cli/main_parser.py", line 7, in <module>
from pip._internal.cli import cmdoptions
File "/mnt/afids/install/lib/python3.8/site-packages/pip/_internal/cli/cmdoptions.py", line 18, in <module>
import setuptools
File "/mnt/afids/install/lib/python3.8/site-packages/setuptools/__init__.py", line 10, in <module>
import distutils.core
ModuleNotFoundError: No module named 'distutils'
I’ve searched through many sites and have tried all of the suggestions that I could find over the last 2 days. What I get below seems a common enough problem that there are many answers, but none of them has worked for me. I found this Ask Ubuntu post which suggested I should run this:
sudo apt install python3-distutils
However, it did not work for me:
$ sudo apt install python3-distutils
[sudo] password for rjb:
Package python3-distutils is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
Error: Package 'python3-distutils' has no installation candidate
I am using Ubuntu 24.10 (Oracular Oriole), and Python 3.8.10. I believe I have the configuration right for my system. I have removed and reinstalled python3.8 and pip3.
Any help would be appreciated.
$ which python3.8
/usr/bin/python3.8
$ ls /usr/bin/pyt*
lrwxrwxrwx 1 root root 18 Jun 25 14:14 /usr/bin/python -> /usr/bin/python3.8*
-rwxr-xr-x 1 root root 14244 Jun 17 2022 /usr/bin/python-mkdebian*
lrwxrwxrwx 1 root root 9 Jun 24 08:59 /usr/bin/python3 -> python3.8*
lrwxrwxrwx 1 root root 17 Sep 12 2024 /usr/bin/python3-config -> python3.12-config*
-rwxr-xr-x 1 root root 978 Mar 31 2024 /usr/bin/python3-coverage*
-rwxr-xr-x 1 root root 6752256 Oct 7 2023 /usr/bin/python3.11*
-rwxr-xr-x 1 root root 8059480 Jun 18 06:16 /usr/bin/python3.12*
lrwxrwxrwx 1 root root 34 Jun 18 06:16 /usr/bin/python3.12-config -> x86_64-linux-gnu-python3.12-config*
-rwxr-xr-x 1 root root 981 Mar 31 2024 /usr/bin/python3.12-coverage*
-rwxr-xr-x 1 root root 5502744 Jun 22 2022 /usr/bin/python3.8*
-rwxr-xr-x 1 root root 3053 Jun 25 16:27 /usr/bin/python3.8-config*
$ ls /usr/bin/pip*
lsl /usr/bin/pip*
-rwxr-xr-x 1 root root 221 Oct 17 2024 /usr/bin/pip*
-rwxr-xr-x 1 root root 221 Oct 17 2024 /usr/bin/pip3*
$ which pip3
/usr/bin/pip3
The contents of /mnt/afids/install/lib/python3.8/site-packages:
$ pwd
/mnt/afids/install/lib/python3.8/site-packages
$ ls -l
total 24
-rw-r--r-- 1 rjb rjb 119 Jun 24 19:39 README.txt
drwxr-xr-x 3 rjb rjb 79 Jun 17 12:35 _distutils_hack/
-rw-r--r-- 1 rjb rjb 152 Jun 17 12:35 distutils-precedence.pth
drwxr-xr-x 17 rjb rjb 4096 Jun 20 17:23 numpy/
drwxr-xr-x 2 rjb rjb 183 Jun 20 17:23 numpy-1.19.3.dist-info/
drwxr-xr-x 5 rjb rjb 119 Jun 20 17:52 pip/
drwxr-xr-x 2 rjb rjb 183 Jun 20 17:52 pip-20.3.3.dist-info/
drwxr-xr-x 6 rjb rjb 110 Jun 17 12:35 pkg_resources/
drwxr-xr-x 8 rjb rjb 4096 Jun 26 12:16 setuptools/
drwxr-xr-x 2 rjb rjb 4096 Jun 17 12:35 setuptools-56.0.0.dist-info/
drwxr-xr-x 5 rjb rjb 4096 Jun 20 17:09 wheel/
drwxr-xr-x 2 rjb rjb 158 Jun 20 17:09 wheel-0.45.1.dist-info/
And my /home/rjb/.local/bin/pip3:
#!/usr/bin/python3.8
# -*- coding: utf-8 -*-
import re
import sys
from pip._internal.cli.main import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())
-bash-5.2$ sudo apt install python3-distutils
[sudo] password for rjb:
Package python3-distutils is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
Error: Package 'python3-distutils' has no installation candidate
My system is built on a small OS disk. I have a 12TB data disk called afids which uses /mnt/afids. I have a very large software package to build which includes many libraries built with autotools. I run everything through a bash script calling many configure, compile,link scripts. It builds approximately 50 libraries including python on this disk. The script was delivered as is. I believe it was built on Centos but I have no other information as to what gcc/g++/fortran it was built with
When I try to add the universe repository, I get:
-bash-5.2$ sudo add-apt-repository universe
[sudo] password for rjb:
Traceback (most recent call last):
File "/usr/bin/add-apt-repository", line 3, in <module>
import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'
-bash-5.2$ sudo apt install apt_pkg
Error: Unable to locate package apt_pkg
-bash-5.2$