Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError when running pyproject.toml-based build, since the build-backend can't be found #11770

Closed
1 task done
srepollock opened this issue Jan 31, 2023 · 16 comments
Closed
1 task done
Labels
type: bug A confirmed bug or unintended behavior

Comments

@srepollock
Copy link

srepollock commented Jan 31, 2023

Description

Currently unable to install packages with the latest release of pip

Expected behavior

No response

pip version

23.0

Python version

3.10

OS

docker ubuntu20.04

How to Reproduce

  1. use:
RUN add-apt-repository ppa:deadsnakes/ppa \
    && apt update
# NOTE: Must use python3.10 due to finta 2023-01-30
RUN apt install -y python3.10 python3.10-distutils \
    && ln -fs /usr/bin/python3.10 /usr/bin/python3 \
    && curl -sS https://bootstrap.pypa.io/get-pip.py | python3

Output

#21 0.871 Requirement already satisfied: pip in /usr/local/lib/python3.10/dist-packages (22.3.1)
#21 1.012 Collecting pip
#21 1.018   Using cached pip-23.0-py3-none-any.whl (2.1 MB)
#21 1.093 Installing collected packages: pip
#21 1.093   Attempting uninstall: pip
#21 1.094     Found existing installation: pip 22.3.1
#21 1.260     Uninstalling pip-22.3.1:
#21 1.449       Successfully uninstalled pip-22.3.1
#21 2.530 Successfully installed pip-23.0
#21 2.530 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
#21 3.013 Requirement already satisfied: wheel in /usr/local/lib/python3.10/dist-packages (from -r /requirements.txt (line 2)) (0.38.4)
#21 3.115 Requirement already satisfied: setuptools in /usr/local/lib/python3.10/dist-packages (from -r /requirements.txt (line 3)) (67.0.0)
#21 16.99 Collecting rsa<4.8,>=3.1.2
#21 17.01   Downloading rsa-4.7.2-py3-none-any.whl (34 kB)
#21 17.09 Collecting PyYAML<5.5,>=3.10
#21 17.11   Downloading PyYAML-5.4.1.tar.gz (175 kB)
#21 17.13      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 175.1/175.1 kB 13.2 MB/s eta 0:00:00
#21 17.31   Installing build dependencies: started
#21 20.70   Installing build dependencies: finished with status 'done'
#21 20.70   Getting requirements to build wheel: started
#21 20.74   Getting requirements to build wheel: finished with status 'done'
#21 20.75 ERROR: Exception:
#21 20.75 Traceback (most recent call last):
#21 20.75   File "/usr/local/lib/python3.10/dist-packages/pip/_internal/cli/base_command.py", line 160, in exc_logging_wrapper
#21 20.75     status = run_func(*args)
#21 20.75   File "/usr/local/lib/python3.10/dist-packages/pip/_internal/cli/req_command.py", line 247, in wrapper
#21 20.75     return func(self, options, args)
#21 20.75   File "/usr/local/lib/python3.10/dist-packages/pip/_internal/commands/install.py", line 415, in run
#21 20.75     requirement_set = resolver.resolve(
#21 20.75   File "/usr/local/lib/python3.10/dist-packages/pip/_internal/resolution/resolvelib/resolver.py", line 92, in resolve
#21 20.75     result = self._result = resolver.resolve(
#21 20.75   File "/usr/local/lib/python3.10/dist-packages/pip/_vendor/resolvelib/resolvers.py", line 481, in resolve
#21 20.75     state = resolution.resolve(requirements, max_rounds=max_rounds)
#21 20.75   File "/usr/local/lib/python3.10/dist-packages/pip/_vendor/resolvelib/resolvers.py", line 373, in resolve
#21 20.75     failure_causes = self._attempt_to_pin_criterion(name)
#21 20.75   File "/usr/local/lib/python3.10/dist-packages/pip/_vendor/resolvelib/resolvers.py", line 213, in _attempt_to_pin_criterion
#21 20.75     criteria = self._get_updated_criteria(candidate)
#21 20.75   File "/usr/local/lib/python3.10/dist-packages/pip/_vendor/resolvelib/resolvers.py", line 204, in _get_updated_criteria
#21 20.75     self._add_to_criteria(criteria, requirement, parent=candidate)
#21 20.75   File "/usr/local/lib/python3.10/dist-packages/pip/_vendor/resolvelib/resolvers.py", line 172, in _add_to_criteria
#21 20.75     if not criterion.candidates:
#21 20.75   File "/usr/local/lib/python3.10/dist-packages/pip/_vendor/resolvelib/structs.py", line 151, in __bool__
#21 20.75     return bool(self._sequence)
#21 20.75   File "/usr/local/lib/python3.10/dist-packages/pip/_internal/resolution/resolvelib/found_candidates.py", line 155, in __bool__
#21 20.75     return any(self)
#21 20.75   File "/usr/local/lib/python3.10/dist-packages/pip/_internal/resolution/resolvelib/found_candidates.py", line 143, in <genexpr>
#21 20.75     return (c for c in iterator if id(c) not in self._incompatible_ids)
#21 20.75   File "/usr/local/lib/python3.10/dist-packages/pip/_internal/resolution/resolvelib/found_candidates.py", line 47, in _iter_built
#21 20.75     candidate = func()
#21 20.75   File "/usr/local/lib/python3.10/dist-packages/pip/_internal/resolution/resolvelib/factory.py", line 206, in _make_candidate_from_link
#21 20.75     self._link_candidate_cache[link] = LinkCandidate(
#21 20.75   File "/usr/local/lib/python3.10/dist-packages/pip/_internal/resolution/resolvelib/candidates.py", line 297, in __init__
#21 20.75     super().__init__(
#21 20.75   File "/usr/local/lib/python3.10/dist-packages/pip/_internal/resolution/resolvelib/candidates.py", line 162, in __init__
#21 20.75     self.dist = self._prepare()
#21 20.75   File "/usr/local/lib/python3.10/dist-packages/pip/_internal/resolution/resolvelib/candidates.py", line 231, in _prepare
#21 20.75     dist = self._prepare_distribution()
#21 20.75   File "/usr/local/lib/python3.10/dist-packages/pip/_internal/resolution/resolvelib/candidates.py", line 308, in _prepare_distribution
#21 20.75     return preparer.prepare_linked_requirement(self._ireq, parallel_builds=True)
#21 20.75   File "/usr/local/lib/python3.10/dist-packages/pip/_internal/operations/prepare.py", line 491, in prepare_linked_requirement
#21 20.75     return self._prepare_linked_requirement(req, parallel_builds)
#21 20.75   File "/usr/local/lib/python3.10/dist-packages/pip/_internal/operations/prepare.py", line 577, in _prepare_linked_requirement
#21 20.75     dist = _get_prepared_distribution(
#21 20.75   File "/usr/local/lib/python3.10/dist-packages/pip/_internal/operations/prepare.py", line 69, in _get_prepared_distribution
#21 20.75     abstract_dist.prepare_distribution_metadata(
#21 20.75   File "/usr/local/lib/python3.10/dist-packages/pip/_internal/distributions/sdist.py", line 48, in prepare_distribution_metadata
#21 20.75     self._install_build_reqs(finder)
#21 20.75   File "/usr/local/lib/python3.10/dist-packages/pip/_internal/distributions/sdist.py", line 118, in _install_build_reqs
#21 20.75     build_reqs = self._get_build_requires_wheel()
#21 20.75   File "/usr/local/lib/python3.10/dist-packages/pip/_internal/distributions/sdist.py", line 95, in _get_build_requires_wheel
#21 20.75     return backend.get_requires_for_build_wheel()
#21 20.75   File "/usr/local/lib/python3.10/dist-packages/pip/_internal/utils/misc.py", line 701, in get_requires_for_build_wheel
#21 20.75     return super().get_requires_for_build_wheel(config_settings=cs)
#21 20.75   File "/usr/local/lib/python3.10/dist-packages/pip/_vendor/pyproject_hooks/_impl.py", line 166, in get_requires_for_build_wheel
#21 20.75     return self._call_hook('get_requires_for_build_wheel', {
#21 20.75   File "/usr/local/lib/python3.10/dist-packages/pip/_vendor/pyproject_hooks/_impl.py", line 321, in _call_hook
#21 20.75     raise BackendUnavailable(data.get('traceback', ''))
#21 20.75 pip._vendor.pyproject_hooks._impl.BackendUnavailable: Traceback (most recent call last):
#21 20.75   File "/usr/local/lib/python3.10/dist-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 77, in _build_backend
#21 20.75     obj = import_module(mod_path)
#21 20.75   File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
#21 20.75     return _bootstrap._gcd_import(name[level:], package, level)
#21 20.75   File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
#21 20.75   File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
#21 20.75   File "<frozen importlib._bootstrap>", line 992, in _find_and_load_unlocked
#21 20.75   File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
#21 20.75   File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
#21 20.75   File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
#21 20.75   File "<frozen importlib._bootstrap>", line 1004, in _find_and_load_unlocked
#21 20.75 ModuleNotFoundError: No module named 'setuptools'

Code of Conduct

@srepollock srepollock added S: needs triage Issues/PRs that need to be triaged type: bug A confirmed bug or unintended behavior labels Jan 31, 2023
@dnicolodi
Copy link
Contributor

I think this is the issue fixed by #11740.

@pradyunsg pradyunsg removed the S: needs triage Issues/PRs that need to be triaged label Jan 31, 2023
@srepollock
Copy link
Author

Upgraded Dockerfile to use Ubuntu 22.04 did correct the error.

Still seems to be an error for 20.04.

@njzjz
Copy link
Contributor

njzjz commented Jan 31, 2023

What's the workaround for the old ubuntu images? For some reason, I cannot bump the ubuntu version.

@pradyunsg pradyunsg changed the title Errors using setuptools on the latest release of pip pip 23.0: ImportError when running pyproject.toml-based build, since the build-backend can't be found Jan 31, 2023
@vmarkovtsev
Copy link

I am running on 22.04 and this error still happens. Shall we reopen?

@pradyunsg pradyunsg reopened this Jan 31, 2023
njzjz added a commit to njzjz/deepmd-kit that referenced this issue Jan 31, 2023
per pypa/pip#11770

Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
amcadmus added a commit to deepmodeling/deepmd-kit that referenced this issue Feb 1, 2023
@uranusjr
Copy link
Member

uranusjr commented Feb 1, 2023

I can not reproduce on Ubuntu 22.04 with this:

FROM ubuntu:22.04

RUN apt-get update \
 && apt-get install -y software-properties-common \
 && add-apt-repository ppa:deadsnakes/ppa \
 && apt-get update \
 && apt-get install -y build-essential curl python3.10-distutils python3.10-dev \
 && curl -sS https://bootstrap.pypa.io/get-pip.py | python3.10

RUN python3.10 -m pip install --no-binary=pyyaml pyyaml==5.4.1

This builds cleanly. Please provide a reproduction if you see errors.

@srepollock

This comment was marked as off-topic.

@uranusjr

This comment was marked as off-topic.

@srepollock

This comment was marked as off-topic.

kernicPanel added a commit to openfun/marsha that referenced this issue Feb 2, 2023
Last pip version introduces a bug with ubuntu 20
See pypa/pip#11770

So we decided to pin pip to version < 23.0
kernicPanel added a commit to openfun/marsha that referenced this issue Feb 2, 2023
Last pip version introduces a bug with ubuntu 20
See pypa/pip#11770

So we decided to pin pip to version < 23.0
Thanks @jmaupetit @lunika
kernicPanel added a commit to openfun/marsha that referenced this issue Feb 2, 2023
Last pip version introduces a bug with ubuntu 20
See pypa/pip#11770

So we decided to pin pip to version < 23.0
Thanks @jmaupetit @lunika
@pradyunsg
Copy link
Member

Is anyone able to reproduce this on platforms other than Ubuntu 20.04?

@stefanor
Copy link
Contributor

stefanor commented Feb 6, 2023

I can't even reproduce it in an Ubuntu 20.04 container (but not the docker image)

@dnicolodi
Copy link
Contributor

I've reproduced the problem on Ubuntu 20.04 with Python 3.10 from deadsnakes/ppa. I can confirm that #11740 fixes the issue. The reproducer is exactly what @uranusjr posted a few comments above. The stock Python 3.8 is not affected. As the issue goes away with pip master, I haven't tried to understand what is special about this Python on this Ubuntu release to trigger the issue.

Ubuntu 22.04 comes with Python 3.10 and is not affected.

@vmarkovtsev Would you like to share more details about the issue you found?

@pradyunsg pradyunsg changed the title pip 23.0: ImportError when running pyproject.toml-based build, since the build-backend can't be found ImportError when running pyproject.toml-based build, since the build-backend can't be found Feb 6, 2023
@marcinwrochna
Copy link

marcinwrochna commented Feb 6, 2023

I can reproduce with the ubuntu:22.04 image, but with Python 3.11 from deadsnakes, not 3.10 which is already on 22.04 repositories.

podman run -it --rm ubuntu:22.04

apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y software-properties-common curl tzdata
add-apt-repository -y ppa:deadsnakes/ppa
apt-get update && apt-get install -y python3.11-dev
curl https://bootstrap.pypa.io/get-pip.py -sS | python3.11  # Installs pip 23.0, setuptools 67.1.0, wheel 0.38.4
python3.11 -m pip install --no-binary=pyyaml pyyaml==5.4.1  # No module named 'setuptools'

@dnicolodi
Copy link
Contributor

Thank you @marcinwrochna. I confirm that #11740 fixes the issue with Python 3.11 from deadsnakes on Ubuntu 22.04 too.

@pradyunsg I think we can close this issue now as all identified problems are solved by the already merged PR.

@lanadweik
Copy link

lanadweik commented Feb 13, 2023

hello, im having the same trouble but im on my kali linux, and this command is obviously not working. can you please help me with that?

@marcinwrochna
Copy link

@lanadweik At the moment the workaround is to downgrade pip: python -m pip install pip==22.3.1

@dnicolodi
Copy link
Contributor

After you downgrade pip, you can also check that the proposed resolution for this bug works for you too installing pip from the git repository: python -m pip install "pip @ git+https://github.com/pypa/pip.git"

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug A confirmed bug or unintended behavior
Projects
None yet
Development

No branches or pull requests

9 participants