Closed abersheeran closed 2 years ago
the paths are ~a little non standard because we follow what debian chooses to do there (dist-packages instead of site-packages, and usr/local for user-installed things)
as for the pip install location, that looks a little bit broken -- it should end up in /usr/local/lib/python3.10/dist-packages
Use python3.10 get-pip.py --user
can solve it.
please don't close this, there's a bug that needs fixing
@uranusjr -- debian's patch is currently insufficient, I'm working with them to figure out the best way to actually solve this since it seems patching sysconfig is insufficient:
$ docker run --rm -ti debian:testing bash -euxc 'apt-get update >& /dev/null && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends python3.10 python3-distutils curl ca-certificates >& /dev/null && dpkg -l | grep python3.10 && curl --location --silent https://bootstrap.pypa.io/get-pip.py | python3.10 - && ls /usr/local/bin && ls /usr/lib/python3.10/site-packages && python3.10 -m pip --help'
Resolved "debian" as an alias (/etc/containers/registries.conf.d/shortnames.conf)
Trying to pull docker.io/library/debian:testing...
Getting image source signatures
Copying blob e3875f34eeed done
Copying config 9ef6d00d6c done
Writing manifest to image destination
Storing signatures
+ apt-get update
+ DEBIAN_FRONTEND=noninteractive
+ apt-get install -y --no-install-recommends python3.10 python3-distutils curl ca-certificates
+ dpkg -l
+ grep python3.10
ii libpython3.10-minimal:amd64 3.10.1-1 amd64 Minimal subset of the Python language (version 3.10)
ii libpython3.10-stdlib:amd64 3.10.1-1 amd64 Interactive high-level object-oriented language (standard library, version 3.10)
ii python3.10 3.10.1-1 amd64 Interactive high-level object-oriented language (version 3.10)
ii python3.10-minimal 3.10.1-1 amd64 Minimal subset of the Python language (version 3.10)
+ curl --location --silent https://bootstrap.pypa.io/get-pip.py
+ python3.10 -
Collecting pip
Downloading pip-21.3.1-py3-none-any.whl (1.7 MB)
|████████████████████████████████| 1.7 MB 4.5 MB/s
Collecting setuptools
Downloading setuptools-59.5.0-py3-none-any.whl (952 kB)
|████████████████████████████████| 952 kB 50.5 MB/s
Collecting wheel
Downloading wheel-0.37.0-py2.py3-none-any.whl (35 kB)
Installing collected packages: wheel, setuptools, pip
Successfully installed pip-21.3.1 setuptools-59.5.0 wheel-0.37.0
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
+ ls /usr/local/bin
+ ls /usr/lib/python3.10/site-packages
_distutils_hack pip-21.3.1.dist-info setuptools-59.5.0.dist-info
distutils-precedence.pth pkg_resources wheel
pip setuptools wheel-0.37.0.dist-info
+ python3.10 -m pip --help
/usr/bin/python3.10: No module named pip
note that we do patch sysconfig (similar to debian) but it doesn't seem to be enough for pip:
You need to patch Lib/sysconfig.py
, not Lib/distutils/sysconfig.py
(although the latter probably also needs to be patched for other tools that have not migrate away from distutils to continue working). Your (latter) patch adds two entries under _INSTALL_SCHEMES
, but I think you also need some logic to actually choose posix_local
when appropriate. See lines 47 to 71 in this patch. You probably don’t need deb_system
; from what I know it’s used to build .deb
packages for Python libs, which deadsnakes don’t distribute.
yes, but even that patch is insufficient as shown above (debian:testing
has the latest packaged and patched version of debian's python3.10) -- deb_system
can still be relevant if packages are built against it (some companies do)
@asottile it apparently can work in Debian and here is how they made it work: https://stackoverflow.com/a/70138402/9962007
@mirekphd no that's off topic, they built python from source into /usr/local
I debugged a bit in debian-testing
, it seems that sysconfig.get_preferred_scheme()
needs to be patched like the _get_default_scheme()
in 3.9 and prior, so get_preferred_scheme("prefix")
returns either posix_local
or deb_system
(depending on the situation), instead of posix_prefix
as it currently does.
I believe this is fixed now, the apt version for these will look like 3.10.1-1+focal2
-- the 2
being the updated version (for 3.11 it'll be 3
because there was another revision there as well)
I debugged a bit in
debian-testing
, it seems thatsysconfig.get_preferred_scheme()
needs to be patched like the_get_default_scheme()
in 3.9 and prior, soget_preferred_scheme("prefix")
returns eitherposix_local
ordeb_system
(depending on the situation), instead ofposix_prefix
as it currently does.
This behavior is not correct, now the install scheme is wrong when --prefix
option is passed. It should be posix_prefix
while posix_local
is used.
EDIT:
It might need some discussion. I think --prefix
should use posix_prefix
scheme, if not otherwise. And posix_local
should be the default scheme.
What is the behaviour on Debian Testing’s built-in Python? If they have the exact same problem, this should be raised to Debian first to discuss.
we are unaffiliated with debian, please raise any issues with debian to their bug tracker
description
Why
/usr/lib/python3.10/site-packages
not in sys.path?I use the following code to install python3.10 in Ubuntu18.04.
And then run
python3.10 -c 'import sys; print(sys.path)'
, I got:But if run
python3.10 get-pip.py --disable-pip-version-check
to install pip, pip would be in/usr/lib/python3.10/site-packages
.os information
lsb_release -a
uname -a