This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: test_venv: test_with_pip fails on version 3.8.12 with: pip._vendor.packaging.version.InvalidVersion: Invalid version: 'setuptools'
Type: behavior Stage:
Components: Build Versions: Python 3.11, Python 3.10, Python 3.9, Python 3.8
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: sxt1001, thatiparthy, vstinner
Priority: normal Keywords:

Created on 2021-09-16 15:11 by sxt1001, last changed 2022-04-11 14:59 by admin.

Messages (2)
msg401955 - (view) Author: tongxiaoge (sxt1001) Date: 2021-09-16 15:11
Today, I tried to upgrade Python 3 to version 3.8.12, the test case test_with_pip failed. The error message is as follows:
[  356s] test_with_pip (test.test_venv.EnsurePipTest) ... FAIL
[  356s] 
[  356s] ======================================================================
[  356s] FAIL: test_with_pip (test.test_venv.EnsurePipTest)
[  356s] ----------------------------------------------------------------------
[  356s] Traceback (most recent call last):
[  356s]   File "/home/abuild/rpmbuild/BUILD/Python-3.8.12/Lib/test/test_venv.py", line 444, in do_test_with_pip
[  356s]     self.run_with_capture(venv.create, self.env_dir,
[  356s]   File "/home/abuild/rpmbuild/BUILD/Python-3.8.12/Lib/test/test_venv.py", line 77, in run_with_capture
[  356s]     func(*args, **kwargs)
[  356s] subprocess.CalledProcessError: Command '['/tmp/tmpm13zz0cn/bin/python', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1.
[  356s] 
[  356s] During handling of the above exception, another exception occurred:
[  356s] 
[  356s] Traceback (most recent call last):
[  356s]   File "/home/abuild/rpmbuild/BUILD/Python-3.8.12/Lib/test/test_venv.py", line 504, in test_with_pip
[  356s]     self.do_test_with_pip(False)
[  356s]   File "/home/abuild/rpmbuild/BUILD/Python-3.8.12/Lib/test/test_venv.py", line 452, in do_test_with_pip
[  356s]     self.fail(msg.format(exc, details))
[  356s] AssertionError: Command '['/tmp/tmpm13zz0cn/bin/python', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1.
[  356s] 
[  356s] **Subprocess Output**
[  356s] Looking in links: /tmp/tmp7usqy615
[  356s] Processing /tmp/tmp7usqy615/pip-20.3.3-py2.py3-none-any.whl
[  356s] Processing /tmp/tmp7usqy615/setuptools-54.2.0-py3-none-any.whl
[  356s] Installing collected packages: setuptools, pip
[  356s] ERROR: Exception:
[  356s] Traceback (most recent call last):
[  356s]   File "/tmp/tmp7usqy615/pip-20.3.3-py2.py3-none-any.whl/pip/_vendor/packaging/version.py", line 57, in parse
[  356s]     return Version(version)
[  356s]   File "/tmp/tmp7usqy615/pip-20.3.3-py2.py3-none-any.whl/pip/_vendor/packaging/version.py", line 298, in __init__
[  356s]     raise InvalidVersion("Invalid version: '{0}'".format(version))
[  356s] pip._vendor.packaging.version.InvalidVersion: Invalid version: 'setuptools'
[  356s] 
[  356s] During handling of the above exception, another exception occurred:
[  356s] 
[  356s] Traceback (most recent call last):
[  356s]   File "/tmp/tmp7usqy615/pip-20.3.3-py2.py3-none-any.whl/pip/_internal/cli/base_command.py", line 224, in _main
[  356s]     status = self.run(options, args)
[  356s]   File "/tmp/tmp7usqy615/pip-20.3.3-py2.py3-none-any.whl/pip/_internal/cli/req_command.py", line 180, in wrapper
[  356s]     return func(self, options, args)
[  356s]   File "/tmp/tmp7usqy615/pip-20.3.3-py2.py3-none-any.whl/pip/_internal/commands/install.py", line 439, in run
[  356s]     working_set = pkg_resources.WorkingSet(lib_locations)
[  356s]   File "/tmp/tmp7usqy615/pip-20.3.3-py2.py3-none-any.whl/pip/_vendor/pkg_resources/__init__.py", line 567, in __init__
[  356s]     self.add_entry(entry)
[  356s]   File "/tmp/tmp7usqy615/pip-20.3.3-py2.py3-none-any.whl/pip/_vendor/pkg_resources/__init__.py", line 623, in add_entry
[  356s]     for dist in find_distributions(entry, True):
[  356s]   File "/tmp/tmp7usqy615/pip-20.3.3-py2.py3-none-any.whl/pip/_vendor/pkg_resources/__init__.py", line 2061, in find_on_path
[  356s]     path_item_entries = _by_version_descending(filtered)
[  356s]   File "/tmp/tmp7usqy615/pip-20.3.3-py2.py3-none-any.whl/pip/_vendor/pkg_resources/__init__.py", line 2034, in _by_version_descending
[  356s]     return sorted(names, key=_by_version, reverse=True)
[  356s]   File "/tmp/tmp7usqy615/pip-20.3.3-py2.py3-none-any.whl/pip/_vendor/pkg_resources/__init__.py", line 2032, in _by_version
[  356s]     return [packaging.version.parse(part) for part in parts]
[  356s]   File "/tmp/tmp7usqy615/pip-20.3.3-py2.py3-none-any.whl/pip/_vendor/pkg_resources/__init__.py", line 2032, in <listcomp>
[  356s]     return [packaging.version.parse(part) for part in parts]
[  356s]   File "/tmp/tmp7usqy615/pip-20.3.3-py2.py3-none-any.whl/pip/_vendor/packaging/version.py", line 59, in parse
[  356s]     return LegacyVersion(version)
[  356s]   File "/tmp/tmp7usqy615/pip-20.3.3-py2.py3-none-any.whl/pip/_vendor/packaging/version.py", line 127, in __init__
[  356s]     warnings.warn(
[  356s] DeprecationWarning: Creating a LegacyVersion has been deprecated and will be removed in the next major release
[  356s] Traceback (most recent call last):
[  356s]   File "/home/abuild/rpmbuild/BUILD/Python-3.8.12/Lib/runpy.py", line 194, in _run_module_as_main
[  356s]     return _run_code(code, main_globals, None,
[  356s]   File "/home/abuild/rpmbuild/BUILD/Python-3.8.12/Lib/runpy.py", line 87, in _run_code
[  356s]     exec(code, run_globals)
[  356s]   File "/home/abuild/rpmbuild/BUILD/Python-3.8.12/Lib/ensurepip/__main__.py", line 5, in <module>
[  356s]     sys.exit(ensurepip._main())
[  356s]   File "/home/abuild/rpmbuild/BUILD/Python-3.8.12/Lib/ensurepip/__init__.py", line 219, in _main
[  356s]     return _bootstrap(
[  356s]   File "/home/abuild/rpmbuild/BUILD/Python-3.8.12/Lib/ensurepip/__init__.py", line 138, in _bootstrap
[  356s]     return _run_pip(args + [p[0] for p in _PROJECTS], additional_paths)
[  356s]   File "/home/abuild/rpmbuild/BUILD/Python-3.8.12/Lib/ensurepip/__init__.py", line 50, in _run_pip
[  356s]     return subprocess.run([sys.executable, "-c", code], check=True).returncode
[  356s]   File "/home/abuild/rpmbuild/BUILD/Python-3.8.12/Lib/subprocess.py", line 516, in run
[  356s]     raise CalledProcessError(retcode, process.args,
[  356s] subprocess.CalledProcessError: Command '['/tmp/tmpm13zz0cn/bin/python', '-c', '\nimport runpy\nimport sys\nsys.path = [\'/tmp/tmp7usqy615/setuptools-54.2.0-py3-none-any.whl\', \'/tmp/tmp7usqy615/pip-20.3.3-py2.py3-none-any.whl\'] + sys.path\nsys.argv[1:] = [\'install\', \'--no-cache-dir\', \'--no-index\', \'--find-links\', \'/tmp/tmp7usqy615\', \'--upgrade\', \'setuptools\', \'pip\']\nrunpy.run_module("pip", run_name="__main__", alter_sys=True)\n']' returned non-zero exit status 2.
[  356s] 
[  356s] 
[  356s] ----------------------------------------------------------------------
[  356s] 
[  356s] Ran 18 tests in 7.458s


The current version of Python I use is Python 3.8.5. There is no such problem.What is the reason?
msg401957 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-09-16 15:17
> Today, I tried to upgrade Python 3 to version 3.8.12, the test case test_with_pip failed. The error message is as follows:

What is your operating system? How did you install Python? Which command did you type to run tests?
History
Date User Action Args
2022-04-11 14:59:50adminsetgithub: 89385
2021-09-20 06:51:49christian.heimessetnosy: - christian.heimes
2021-09-16 15:20:20vstinnersettitle: test_with_pip fail -> test_venv: test_with_pip fails on version 3.8.12 with: pip._vendor.packaging.version.InvalidVersion: Invalid version: 'setuptools'
2021-09-16 15:17:07vstinnersetmessages: + msg401957
2021-09-16 15:14:55sxt1001settype: behavior
components: + Build
2021-09-16 15:11:41sxt1001create