deadsnakes / issues

Issues for https://launchpad.net/~deadsnakes/+archive/ubuntu/ppa
86 stars 6 forks source link

python3.9 can't use pip #200

Closed clayote closed 2 years ago

clayote commented 2 years ago

description

python3.9 can't import the system-wide distutils, and therefore, cannot use pip.

sanotehu@sanotehu-MS-7A31:~/src/LiSE$ sudo apt install python3.9
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  libpython3.9-minimal libpython3.9-stdlib python3.9-minimal
Suggested packages:
  python3.9-venv
The following NEW packages will be installed:
  libpython3.9-minimal libpython3.9-stdlib python3.9 python3.9-minimal
0 upgraded, 4 newly installed, 0 to remove and 0 not upgraded.
Need to get 4,885 kB of archives.
After this operation, 19.4 MB of additional disk space will be used.
Do you want to continue? [Y/n] 
Get:1 http://ppa.launchpad.net/deadsnakes/ppa/ubuntu focal/main amd64 libpython3.9-minimal amd64 3.9.10-1+focal1 [789 kB]
Get:2 http://ppa.launchpad.net/deadsnakes/ppa/ubuntu focal/main amd64 python3.9-minimal amd64 3.9.10-1+focal1 [1,918 kB]
Get:3 http://ppa.launchpad.net/deadsnakes/ppa/ubuntu focal/main amd64 libpython3.9-stdlib amd64 3.9.10-1+focal1 [1,694 kB]
Get:4 http://ppa.launchpad.net/deadsnakes/ppa/ubuntu focal/main amd64 python3.9 amd64 3.9.10-1+focal1 [484 kB]
Fetched 4,885 kB in 3s (1,782 kB/s)
Selecting previously unselected package libpython3.9-minimal:amd64.
(Reading database ... 488195 files and directories currently installed.)
Preparing to unpack .../libpython3.9-minimal_3.9.10-1+focal1_amd64.deb ...
Unpacking libpython3.9-minimal:amd64 (3.9.10-1+focal1) ...
Selecting previously unselected package python3.9-minimal.
Preparing to unpack .../python3.9-minimal_3.9.10-1+focal1_amd64.deb ...
Unpacking python3.9-minimal (3.9.10-1+focal1) ...
Selecting previously unselected package libpython3.9-stdlib:amd64.
Preparing to unpack .../libpython3.9-stdlib_3.9.10-1+focal1_amd64.deb ...
Unpacking libpython3.9-stdlib:amd64 (3.9.10-1+focal1) ...
Selecting previously unselected package python3.9.
Preparing to unpack .../python3.9_3.9.10-1+focal1_amd64.deb ...
Unpacking python3.9 (3.9.10-1+focal1) ...
Setting up libpython3.9-minimal:amd64 (3.9.10-1+focal1) ...
Setting up python3.9-minimal (3.9.10-1+focal1) ...
Setting up libpython3.9-stdlib:amd64 (3.9.10-1+focal1) ...
Setting up python3.9 (3.9.10-1+focal1) ...
Processing triggers for mime-support (3.64ubuntu1) ...
Processing triggers for gnome-menus (3.36.0-1ubuntu1) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for desktop-file-utils (0.24+linuxmint1) ...
sanotehu@sanotehu-MS-7A31:~/src/LiSE$ python3.9 -m pip install --user numpy
Traceback (most recent call last):
  File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/usr/lib/python3/dist-packages/pip/__main__.py", line 16, in <module>
    from pip._internal.cli.main import main as _main  # isort:skip # noqa
  File "/usr/lib/python3/dist-packages/pip/_internal/cli/main.py", line 10, in <module>
    from pip._internal.cli.autocompletion import autocomplete
  File "/usr/lib/python3/dist-packages/pip/_internal/cli/autocompletion.py", line 9, in <module>
    from pip._internal.cli.main_parser import create_main_parser
  File "/usr/lib/python3/dist-packages/pip/_internal/cli/main_parser.py", line 7, in <module>
    from pip._internal.cli import cmdoptions
  File "/usr/lib/python3/dist-packages/pip/_internal/cli/cmdoptions.py", line 19, in <module>
    from distutils.util import strtobool
ModuleNotFoundError: No module named 'distutils.util'

os information

lsb_release -a

No LSB modules are available.
Distributor ID: Linuxmint
Description:    Linux Mint 20.3
Release:    20.3
Codename:   una

uname -a

Linux sanotehu-MS-7A31 5.13.0-30-generic #33~20.04.1-Ubuntu SMP Mon Feb 7 14:25:10 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
asottile commented 2 years ago

from the PPA page

  • python#.#-distutils: provides the standard library distutils module

you need to install that (it may be python3-distutils depending on your OS)

in the future please search the issue tracker and the docs! there's a bunch of duplicates and a quick ^F distutils would have saved you the trouble

clayote commented 2 years ago

There is no python3.9-distutils! It's a virtual package pointing to python3-distutils

clayote commented 2 years ago
sanotehu@sanotehu-MS-7A31:~/src/LiSE$ sudo apt install python3.9-distutils
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Note, selecting 'python3-distutils' instead of 'python3.9-distutils'
python3-distutils is already the newest version (3.8.10-0ubuntu1~20.04).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
clayote commented 2 years ago

pip still isn't working after I do that, if that's not obvious??

asottile commented 2 years ago

There is no python3.9-distutils! It's a virtual package pointing to python3-distutils

take a second to read please: (it may be python3-distutils depending on your OS)


I can only assume you've done something very wrong (like sudo rm -rf /usr/lib/python3.9 to end up in this state since the python3-distutils package provides distutils/util.py for python3.9:

$ dpkg -L python3-distutils | grep distutils/util
/usr/lib/python3.8/distutils/util.py
/usr/lib/python3.9/distutils/util.py
$ dpkg -L python3-distutils | grep distutils/util | xargs ls -al
-rw-r--r-- 1 root root 20892 May 11  2021 /usr/lib/python3.8/distutils/util.py
-rw-r--r-- 1 root root 20913 May 11  2021 /usr/lib/python3.9/distutils/util.py
clayote commented 2 years ago

It's not there for me...

sanotehu@sanotehu-MS-7A31:~/src/LiSE$ dpkg -L python3-distutils | grep distutils/util
/usr/lib/python3.8/distutils/util.py
/usr/lib/python3.9/distutils/util.py
sanotehu@sanotehu-MS-7A31:~/src/LiSE$ dpkg -L python3-distutils | grep distutils/util | xargs ls -al
ls: cannot access '/usr/lib/python3.9/distutils/util.py': No such file or directory
-rw-r--r-- 1 root root 20892 May 11  2021 /usr/lib/python3.8/distutils/util.py
clayote commented 2 years ago

I did an uninstall/reinstall just in case

clayote commented 2 years ago
sanotehu@sanotehu-MS-7A31:~/src/LiSE$ ls /usr/lib/python3.9/distutils
__init__.py  __pycache__  version.py

I guess there's supposed to be some symlinks here?

asottile commented 2 years ago

if dpkg -L says the file should be there and it's not there then that's on you

clayote commented 2 years ago

Purged things to be safe... there was some python3.9-minimal and libpython3 configuration files hanging around that I thought might have been causing problems

sanotehu@sanotehu-MS-7A31:~/src/LiSE$ ls /usr/lib/python3.9
ls: cannot access '/usr/lib/python3.9': No such file or directory

Installed fresh...

sanotehu@sanotehu-MS-7A31:~/src/LiSE$ sudo apt install python3.9 python3.9-distutils
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Note, selecting 'python3-distutils' instead of 'python3.9-distutils'
python3-distutils is already the newest version (3.8.10-0ubuntu1~20.04).
The following additional packages will be installed:
  libpython3.9-minimal libpython3.9-stdlib python3.9-minimal
Suggested packages:
  python3.9-venv
The following NEW packages will be installed:
  libpython3.9-minimal libpython3.9-stdlib python3.9 python3.9-minimal
0 upgraded, 4 newly installed, 0 to remove and 0 not upgraded.
Need to get 4,885 kB of archives.
After this operation, 19.4 MB of additional disk space will be used.
Do you want to continue? [Y/n] 
Get:1 http://ppa.launchpad.net/deadsnakes/ppa/ubuntu focal/main amd64 libpython3.9-minimal amd64 3.9.10-1+focal1 [789 kB]
Get:2 http://ppa.launchpad.net/deadsnakes/ppa/ubuntu focal/main amd64 python3.9-minimal amd64 3.9.10-1+focal1 [1,918 kB]
Get:3 http://ppa.launchpad.net/deadsnakes/ppa/ubuntu focal/main amd64 libpython3.9-stdlib amd64 3.9.10-1+focal1 [1,694 kB]
Get:4 http://ppa.launchpad.net/deadsnakes/ppa/ubuntu focal/main amd64 python3.9 amd64 3.9.10-1+focal1 [484 kB]
Fetched 4,885 kB in 3s (1,679 kB/s)                 
Selecting previously unselected package libpython3.9-minimal:amd64.
(Reading database ... 488193 files and directories currently installed.)
Preparing to unpack .../libpython3.9-minimal_3.9.10-1+focal1_amd64.deb ...
Unpacking libpython3.9-minimal:amd64 (3.9.10-1+focal1) ...
Selecting previously unselected package python3.9-minimal.
Preparing to unpack .../python3.9-minimal_3.9.10-1+focal1_amd64.deb ...
Unpacking python3.9-minimal (3.9.10-1+focal1) ...
Selecting previously unselected package libpython3.9-stdlib:amd64.
Preparing to unpack .../libpython3.9-stdlib_3.9.10-1+focal1_amd64.deb ...
Unpacking libpython3.9-stdlib:amd64 (3.9.10-1+focal1) ...
Selecting previously unselected package python3.9.
Preparing to unpack .../python3.9_3.9.10-1+focal1_amd64.deb ...
Unpacking python3.9 (3.9.10-1+focal1) ...
Setting up libpython3.9-minimal:amd64 (3.9.10-1+focal1) ...
Setting up python3.9-minimal (3.9.10-1+focal1) ...
Setting up libpython3.9-stdlib:amd64 (3.9.10-1+focal1) ...
Setting up python3.9 (3.9.10-1+focal1) ...
Processing triggers for mime-support (3.64ubuntu1) ...
Processing triggers for gnome-menus (3.36.0-1ubuntu1) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for desktop-file-utils (0.24+linuxmint1) ...

But no luck.

sanotehu@sanotehu-MS-7A31:~/src/LiSE$ python3.9 -m pip install --user numpy
Traceback (most recent call last):
  File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/usr/lib/python3/dist-packages/pip/__main__.py", line 16, in <module>
    from pip._internal.cli.main import main as _main  # isort:skip # noqa
  File "/usr/lib/python3/dist-packages/pip/_internal/cli/main.py", line 10, in <module>
    from pip._internal.cli.autocompletion import autocomplete
  File "/usr/lib/python3/dist-packages/pip/_internal/cli/autocompletion.py", line 9, in <module>
    from pip._internal.cli.main_parser import create_main_parser
  File "/usr/lib/python3/dist-packages/pip/_internal/cli/main_parser.py", line 7, in <module>
    from pip._internal.cli import cmdoptions
  File "/usr/lib/python3/dist-packages/pip/_internal/cli/cmdoptions.py", line 19, in <module>
    from distutils.util import strtobool
ModuleNotFoundError: No module named 'distutils.util'
clayote commented 2 years ago
sanotehu@sanotehu-MS-7A31:~/src/LiSE$ ls /usr/lib/python3.9/distutils
__init__.py  __pycache__  version.py
asottile commented 2 years ago

python3-distutils is already the newest version (3.8.10-0ubuntu1~20.04).

I can't help you, you've done some dumb things to your system with sudo that I can't see (because you haven't shown me). stop running sudo rm on things managed by the package manager. your python3-distutils package is missing files that you've deleted with sudo for some unknown reason

clayote commented 2 years ago

For anyone else who finds this, the magic command was sudo apt reinstall python3-distutils

asottile commented 2 years ago

presumably noone will have run sudo rm -rf /usr/lib/python3.9 to get themselves into your mess in the first place