Open selfagency opened 1 year ago
Looks like a pip issue: https://github.com/pypa/pip/issues/11319
I experienced the same error.
I understand that it is a pip error, but if topgrade would update pip first (python3 -m pip install --upgrade pip), it would prevent the users from experiencing this error in the future.
Requirement already satisfied: pip in ./.local/lib/python3.8/site-packages (22.2)
Collecting pip
Using cached pip-22.2.1-py3-none-any.whl (2.0 MB)
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 22.2
Uninstalling pip-22.2:
Successfully uninstalled pip-22.2
Rolling back uninstall of pip
Moving to /home/toshihiro/.local/bin/pip
from /tmp/pip-uninstall-37ltymkz/pip
Moving to /home/toshihiro/.local/bin/pip3
from /tmp/pip-uninstall-37ltymkz/pip3
Moving to /home/toshihiro/.local/bin/pip3.8
from /tmp/pip-uninstall-37ltymkz/pip3.8
Moving to /home/toshihiro/.local/lib/python3.8/site-packages/pip-22.2.dist-info/
from /home/toshihiro/.local/lib/python3.8/site-packages/~ip-22.2.dist-info
Moving to /home/toshihiro/.local/lib/python3.8/site-packages/pip/
from /home/toshihiro/.local/lib/python3.8/site-packages/~ip
ERROR: Exception:
Traceback (most recent call last):
File "/home/toshihiro/.local/lib/python3.8/site-packages/pip/_internal/cli/base_command.py", line 167, in exc_logging_wrapper
status = run_func(*args)
File "/home/toshihiro/.local/lib/python3.8/site-packages/pip/_internal/cli/req_command.py", line 247, in wrapper
return func(self, options, args)
File "/home/toshihiro/.local/lib/python3.8/site-packages/pip/_internal/commands/install.py", line 461, in run
installed = install_given_reqs(
File "/home/toshihiro/.local/lib/python3.8/site-packages/pip/_internal/req/__init__.py", line 73, in install_given_reqs
requirement.install(
File "/home/toshihiro/.local/lib/python3.8/site-packages/pip/_internal/req/req_install.py", line 752, in install
scheme = get_scheme(
File "/home/toshihiro/.local/lib/python3.8/site-packages/pip/_internal/locations/__init__.py", line 244, in get_scheme
from . import _distutils
ImportError: cannot import name '_distutils' from 'pip._internal.locations' (/home/toshihiro/.local/lib/python3.8/site-packages/pip/_internal/locations/__init__.py)
Are you sure? By my understanding, upgrading pip first would just make it fail sooner. I don't think it's within topgrade's scope to account for unexpected behavior of tools like pip.
Since topgrade is doing carefully rustup
before the cargo update
, it would be nice to have the same behavior for pip, by updating the pip itself before the pip update
. However, I also understand the policy of not addressing it because it is a pip-specific error, as you mentioned.
By my understanding, rustup runs so any following cargo builds don't fail due to an outdated toolchain. If the same can be said about pip (i wouldn't know), that's a valid argument. But this issue is more akin to rustup update
failing with a segfault - at which point we run it is not really relevant, it's an upstream issue either way.
In my experience, there have been several times when the latest version of some library failed to install because the pip was out of date. So, in my mind, if pip fails, the right thing to do is to upgrade pip itself.
However, it seems that the upgrade of pip itself can cause problems in a Windows environment, although I don't use Windows very often. https://github.com/pypa/pip/issues/9395
So, I reconsider that it may be a hasty decision to include the upgrade function of pip itself in topgrade as a default behavior.
Until this has been fixed in pip 22.2.2, you can update pip manually using this command (from https://github.com/pypa/pip/issues/11319#issuecomment-1200119836).
python -m pip install --user --upgrade https://github.com/pypa/pip/archive/refs/tags/22.2.1.zip
# python3 -m pip install --user --upgrade https://github.com/pypa/pip/archive/refs/tags/22.2.1.zip
What did you expect to happen?
Python packages should have updated. Running
pip3 list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip3 install -U
works without issue.What actually happened?
Additional Details
This won't help because I ran it after I manually upgraded the packages:
Same here: