pip imports the deprecated distutils module
See original GitHub issueDescription
The pip/_internal/locations/_distutils.py
file imports the distutils module: https://github.com/pypa/pip/blob/cb24fb4052ca8ab8009866b0de61980c81a7e13c/src/pip/_internal/locations/_distutils.py#L9-L12
This module is deprecated since Python 3.10 and is going to be removed in Python 3.12: https://github.com/python/cpython/issues/92584#issue-1230326042
Expected behavior
No response
pip version
22.0.4
Python version
3.12.0a0
OS
Linux
How to Reproduce
- Build Python 3.12 with https://github.com/python/cpython/pull/92585 PR
- Create a venv without pip:
./python -m venv env
- Install pip:
./env/bin/python -m ensurepip -v
Output
vstinner@apu$ ./env/bin/python -m ensurepip -v
Traceback (most recent call last):
File "<string>", line 6, in <module>
File "/home/vstinner/python/main/Lib/runpy.py", line 226, in run_module
return _run_module_code(code, init_globals, run_name, mod_spec)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/vstinner/python/main/Lib/runpy.py", line 98, in _run_module_code
_run_code(code, mod_globals, init_globals,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/vstinner/python/main/Lib/runpy.py", line 88, in _run_code
exec(code, run_globals)
^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/tmps2pazori/pip-22.0.4-py3-none-any.whl/pip/__main__.py", line 29, in <module>
File "/tmp/tmps2pazori/pip-22.0.4-py3-none-any.whl/pip/_internal/cli/main.py", line 9, in <module>
File "/tmp/tmps2pazori/pip-22.0.4-py3-none-any.whl/pip/_internal/cli/autocompletion.py", line 10, in <module>
File "/tmp/tmps2pazori/pip-22.0.4-py3-none-any.whl/pip/_internal/cli/main_parser.py", line 8, in <module>
File "/tmp/tmps2pazori/pip-22.0.4-py3-none-any.whl/pip/_internal/cli/cmdoptions.py", line 23, in <module>
File "/tmp/tmps2pazori/pip-22.0.4-py3-none-any.whl/pip/_internal/cli/parser.py", line 12, in <module>
File "/tmp/tmps2pazori/pip-22.0.4-py3-none-any.whl/pip/_internal/configuration.py", line 26, in <module>
File "/tmp/tmps2pazori/pip-22.0.4-py3-none-any.whl/pip/_internal/utils/logging.py", line 27, in <module>
File "/tmp/tmps2pazori/pip-22.0.4-py3-none-any.whl/pip/_internal/utils/misc.py", line 39, in <module>
File "/tmp/tmps2pazori/pip-22.0.4-py3-none-any.whl/pip/_internal/locations/__init__.py", line 14, in <module>
File "/tmp/tmps2pazori/pip-22.0.4-py3-none-any.whl/pip/_internal/locations/_distutils.py", line 9, in <module>
ModuleNotFoundError: No module named 'distutils'
Traceback (most recent call last):
File "/home/vstinner/python/main/Lib/runpy.py", line 198, in _run_module_as_main
return _run_code(code, main_globals, None,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/vstinner/python/main/Lib/runpy.py", line 88, in _run_code
exec(code, run_globals)
^^^^^^^^^^^^^^^^^^^^^^^
File "/home/vstinner/python/main/Lib/ensurepip/__main__.py", line 5, in <module>
sys.exit(ensurepip._main())
^^^^^^^^^^^^^^^^^
File "/home/vstinner/python/main/Lib/ensurepip/__init__.py", line 276, in _main
return _bootstrap(
^^^^^^^^^^^
File "/home/vstinner/python/main/Lib/ensurepip/__init__.py", line 192, in _bootstrap
return _run_pip([*args, *_PACKAGE_NAMES], additional_paths)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/vstinner/python/main/Lib/ensurepip/__init__.py", line 92, in _run_pip
return subprocess.run([sys.executable, '-W', 'ignore::DeprecationWarning',
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/vstinner/python/main/Lib/subprocess.py", line 558, in run
raise CalledProcessError(retcode, process.args,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
subprocess.CalledProcessError: Command '['/home/vstinner/python/main/env/bin/python', '-W', 'ignore::DeprecationWarning', '-c', '\nimport runpy\nimport sys\nsys.path = [\'/tmp/tmps2pazori/setuptools-58.1.0-py3-none-any.whl\', \'/tmp/tmps2pazori/pip-22.0.4-py3-none-any.whl\'] + sys.path\nsys.argv[1:] = [\'install\', \'--no-cache-dir\', \'--no-index\', \'--find-links\', \'/tmp/tmps2pazori\', \'-v\', \'setuptools\', \'pip\']\nrunpy.run_module("pip", run_name="__main__", alter_sys=True)\n']' returned non-zero exit status 1.
Code of Conduct
- I agree to follow the PSF Code of Conduct.
Issue Analytics
- State:
- Created a year ago
- Comments:20 (19 by maintainers)
Top Results From Across the Web
PEP 632 – Deprecate distutils module
In Python 3.10 and 3.11, distutils will be formally marked as deprecated. All known issues will be closed at this time. import distutils...
Read more >How can one fully replace distutils, which is deprecated in 3.10?
According to PEP 632, distutils will be formally marked as deprecated, and in Python 3.12, it will be removed. My product is soon...
Read more >distutils package is deprecated and slated for removal in ...
Issue #6752 - DeprecationWarning: distutils package is deprecated and slated for removal in Python 3.12. Here's the place for discussion related ...
Read more >6. Distutils Examples - Setuptools - Python Packaging Authority
If you're just distributing a couple of modules, especially if they don't live in a particular package, you can specify them individually using...
Read more >The entire distutils package is deprecated, to be removed in ...
Pip has been silently replacing distutils with setuptools when installing packages for a long time already, and the distutils documentation has stated that...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ll try to find some time this weekend.
Unless someone plans to work on this in the coming days, I’m going to push this to down to 22.3.