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

Dependency resolution failures produce very unfriendly error messages #1639

Open
1 task done
borice opened this issue Jan 20, 2023 · 1 comment
Open
1 task done
Labels
🐛 bug Something isn't working

Comments

@borice
Copy link

borice commented Jan 20, 2023

  • I have searched the issue tracker and believe that this is not a duplicate.

Make sure you run commands with -v flag before pasting the output.

Steps to reproduce

pdm init -n
pdm add tensorflow numpy pandas matplotlib ipykernel

Actual behavior

Dependency resolution fails, as expected, but the errors are pretty "brutal".

ERRORS:
add tensorflow failed:
Traceback (most recent call last):
  File "/Users/capitanu/.pyenv/versions/3.8.12/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/Users/capitanu/Library/Application Support/pdm/venv/lib/python3.8/site-packages/pdm/installers/synchronizers.py", line 236, in install_candidate
    self.manager.install(can)
  File "/Users/capitanu/Library/Application Support/pdm/venv/lib/python3.8/site-packages/pdm/installers/manager.py", line 39, in install
    installer(str(prepared.build()), self.environment, prepared.direct_url())
  File "/Users/capitanu/Library/Application Support/pdm/venv/lib/python3.8/site-packages/pdm/models/candidates.py", line 362, in build
    self.obtain(allow_all=False)
  File "/Users/capitanu/Library/Application Support/pdm/venv/lib/python3.8/site-packages/pdm/models/candidates.py", line 414, in obtain
    raise CandidateNotFound(
pdm.exceptions.CandidateNotFound: No candidate is found for `tensorflow` that matches the environment or hashes
add h5py failed:
Traceback (most recent call last):
  File "/Users/capitanu/.pyenv/versions/3.8.12/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/Users/capitanu/Library/Application Support/pdm/venv/lib/python3.8/site-packages/pdm/installers/synchronizers.py", line 236, in install_candidate
    self.manager.install(can)
  File "/Users/capitanu/Library/Application Support/pdm/venv/lib/python3.8/site-packages/pdm/installers/manager.py", line 39, in install
    installer(str(prepared.build()), self.environment, prepared.direct_url())
  File "/Users/capitanu/Library/Application Support/pdm/venv/lib/python3.8/site-packages/pdm/models/candidates.py", line 378, in build
    builder.build(build_dir, metadata_directory=self._metadata_dir)
  File "/Users/capitanu/Library/Application Support/pdm/venv/lib/python3.8/site-packages/pdm/builders/wheel.py", line 30, in build
    filename = self._hook.build_wheel(out_dir, config_settings, metadata_directory)
  File "/Users/capitanu/Library/Application Support/pdm/venv/lib/python3.8/site-packages/pyproject_hooks/_impl.py", line 209, in build_wheel
    return self._call_hook('build_wheel', {
  File "/Users/capitanu/Library/Application Support/pdm/venv/lib/python3.8/site-packages/pyproject_hooks/_impl.py", line 311, in _call_hook
    self._subprocess_runner(
  File "/Users/capitanu/Library/Application Support/pdm/venv/lib/python3.8/site-packages/pdm/builders/base.py", line 261, in subprocess_runner
    return log_subprocessor(cmd, cwd, extra_environ=env)
  File "/Users/capitanu/Library/Application Support/pdm/venv/lib/python3.8/site-packages/pdm/builders/base.py", line 107, in log_subprocessor
    raise build_error(e) from None
pdm.exceptions.BuildError: Build backend raised error: Module 'Cython' is missing, please make sure it is specified in the 'build-system.requires' section. If it is not
possible, add it to the project and use '--no-isolation' option.
Showing the last 10 lines of the build output:
    self.run_command(cmd_name)
  File "/var/folders/sx/slyqb94j7533_qcdhwzr_rm80000gn/T/pdm-build-env-oovm9ru7-shared/lib/python3.11/site-packages/setuptools/_distutils/cmd.py", line 318, in run_command
    self.distribution.run_command(command)
  File "/var/folders/sx/slyqb94j7533_qcdhwzr_rm80000gn/T/pdm-build-env-oovm9ru7-shared/lib/python3.11/site-packages/setuptools/dist.py", line 1213, in run_command
    super().run_command(command)
  File "/var/folders/sx/slyqb94j7533_qcdhwzr_rm80000gn/T/pdm-build-env-oovm9ru7-shared/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
    cmd_obj.run()
  File "/private/var/folders/sx/slyqb94j7533_qcdhwzr_rm80000gn/T/pdm-build-io2c5qk2/setup_build.py", line 161, in run
    from Cython.Build import cythonize
ModuleNotFoundError: No module named 'Cython'
add scipy failed:
Traceback (most recent call last):
  File "/Users/capitanu/.pyenv/versions/3.8.12/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/Users/capitanu/Library/Application Support/pdm/venv/lib/python3.8/site-packages/pdm/installers/synchronizers.py", line 236, in install_candidate
    self.manager.install(can)
  File "/Users/capitanu/Library/Application Support/pdm/venv/lib/python3.8/site-packages/pdm/installers/manager.py", line 39, in install
    installer(str(prepared.build()), self.environment, prepared.direct_url())
  File "/Users/capitanu/Library/Application Support/pdm/venv/lib/python3.8/site-packages/pdm/models/candidates.py", line 378, in build
    builder.build(build_dir, metadata_directory=self._metadata_dir)
  File "/Users/capitanu/Library/Application Support/pdm/venv/lib/python3.8/site-packages/pdm/builders/wheel.py", line 27, in build
    self.install(self._requires, shared=True)
  File "/Users/capitanu/Library/Application Support/pdm/venv/lib/python3.8/site-packages/pdm/builders/base.py", line 298, in install
    install_requirements(missing, env)
  File "/Users/capitanu/Library/Application Support/pdm/venv/lib/python3.8/site-packages/pdm/installers/core.py", line 45, in install_requirements
    manager.install(candidate)
  File "/Users/capitanu/Library/Application Support/pdm/venv/lib/python3.8/site-packages/pdm/installers/manager.py", line 39, in install
    installer(str(prepared.build()), self.environment, prepared.direct_url())
  File "/Users/capitanu/Library/Application Support/pdm/venv/lib/python3.8/site-packages/pdm/models/candidates.py", line 378, in build
    builder.build(build_dir, metadata_directory=self._metadata_dir)
  File "/Users/capitanu/Library/Application Support/pdm/venv/lib/python3.8/site-packages/pdm/builders/wheel.py", line 30, in build
    filename = self._hook.build_wheel(out_dir, config_settings, metadata_directory)
  File "/Users/capitanu/Library/Application Support/pdm/venv/lib/python3.8/site-packages/pyproject_hooks/_impl.py", line 209, in build_wheel
    return self._call_hook('build_wheel', {
  File "/Users/capitanu/Library/Application Support/pdm/venv/lib/python3.8/site-packages/pyproject_hooks/_impl.py", line 311, in _call_hook
    self._subprocess_runner(
  File "/Users/capitanu/Library/Application Support/pdm/venv/lib/python3.8/site-packages/pdm/builders/base.py", line 261, in subprocess_runner
    return log_subprocessor(cmd, cwd, extra_environ=env)
  File "/Users/capitanu/Library/Application Support/pdm/venv/lib/python3.8/site-packages/pdm/builders/base.py", line 107, in log_subprocessor
    raise build_error(e) from None
pdm.exceptions.BuildError: Build backend raised error: Showing the last 10 lines of the build output:
           ^^^^^^
  File "/private/var/folders/sx/slyqb94j7533_qcdhwzr_rm80000gn/T/pdm-build-n79aad96/numpy/distutils/fcompiler/gnu.py", line 353, in get_flags_linker_so
    flags = GnuFCompiler.get_flags_linker_so(self)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/private/var/folders/sx/slyqb94j7533_qcdhwzr_rm80000gn/T/pdm-build-n79aad96/numpy/distutils/fcompiler/gnu.py", line 144, in get_flags_linker_so
    os.environ['MACOSX_DEPLOYMENT_TARGET'] = target
    ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen os>", line 684, in __setitem__
  File "<frozen os>", line 758, in encode
TypeError: str expected, not int

See /var/folders/sx/slyqb94j7533_qcdhwzr_rm80000gn/T/pdm-install-c57rmmcu.log for detailed debug log.
[InstallationError]: Some package operations are not complete yet

Expected behavior

Dependency resolution fails, but error messages are more "user friendly".
For comparison, here's the output from Poetry:

poetry init -n
poetry add  tensorflow numpy pandas matplotlib ipykernel

Error output:

The current project's Python requirement (>=3.8,<4.0) is not compatible with some of the required packages Python requirement:
  - tensorflow-io-gcs-filesystem requires Python >=3.7, <3.12, so it will not be satisfied for Python >=3.12,<4.0
  - tensorflow-io-gcs-filesystem requires Python >=3.7, <3.11, so it will not be satisfied for Python >=3.11,<4.0
  - tensorflow-io-gcs-filesystem requires Python >=3.7, <3.11, so it will not be satisfied for Python >=3.11,<4.0
  - tensorflow-io-gcs-filesystem requires Python >=3.7, <3.11, so it will not be satisfied for Python >=3.11,<4.0
  - tensorflow-io-gcs-filesystem requires Python >=3.7, <3.11, so it will not be satisfied for Python >=3.11,<4.0
  - tensorflow-io-gcs-filesystem requires Python >=3.7, <3.11, so it will not be satisfied for Python >=3.11,<4.0
  - tensorflow-io-gcs-filesystem requires Python >=3.7, <3.11, so it will not be satisfied for Python >=3.11,<4.0

Because no versions of tensorflow-io-gcs-filesystem match >0.23.1,<0.24.0 || >0.24.0,<0.25.0 || >0.25.0,<0.26.0 || >0.26.0,<0.27.0 || >0.27.0,<0.28.0 || >0.28.0,<0.29.0 || >0.29.0
 and tensorflow-io-gcs-filesystem (0.23.1) requires Python >=3.7, <3.11, tensorflow-io-gcs-filesystem is forbidden.
And because tensorflow-io-gcs-filesystem (0.24.0) requires Python >=3.7, <3.11
 and tensorflow-io-gcs-filesystem (0.25.0) requires Python >=3.7, <3.11, tensorflow-io-gcs-filesystem is forbidden.
And because tensorflow-io-gcs-filesystem (0.26.0) requires Python >=3.7, <3.11
 and tensorflow-io-gcs-filesystem (0.27.0) requires Python >=3.7, <3.11, tensorflow-io-gcs-filesystem is forbidden.
And because tensorflow-io-gcs-filesystem (0.28.0) requires Python >=3.7, <3.11
 and tensorflow-io-gcs-filesystem (0.29.0) requires Python >=3.7, <3.12, tensorflow-io-gcs-filesystem is forbidden.
Because no versions of tensorflow match >2.11.0,<3.0.0
 and tensorflow (2.11.0) depends on tensorflow-io-gcs-filesystem (>=0.23.1), tensorflow (>=2.11.0,<3.0.0) requires tensorflow-io-gcs-filesystem (>=0.23.1).
Thus, tensorflow is forbidden.
So, because poetry-test depends on tensorflow (^2.11.0), version solving failed.

  • Check your dependencies Python requirement: The Python requirement can be specified via the `python` or `markers` properties

    For tensorflow-io-gcs-filesystem, a possible solution would be to set the `python` property to ">=3.8,<3.12"
    For tensorflow-io-gcs-filesystem, a possible solution would be to set the `python` property to ">=3.8,<3.11"
    For tensorflow-io-gcs-filesystem, a possible solution would be to set the `python` property to ">=3.8,<3.11"
    For tensorflow-io-gcs-filesystem, a possible solution would be to set the `python` property to ">=3.8,<3.11"
    For tensorflow-io-gcs-filesystem, a possible solution would be to set the `python` property to ">=3.8,<3.11"
    For tensorflow-io-gcs-filesystem, a possible solution would be to set the `python` property to ">=3.8,<3.11"
    For tensorflow-io-gcs-filesystem, a possible solution would be to set the `python` property to ">=3.8,<3.11"

    https://python-poetry.org/docs/dependency-specification/#python-restricted-dependencies,
    https://python-poetry.org/docs/dependency-specification/#using-environment-markers

Environment Information

# Paste the output of `pdm info && pdm info --env` below:
$ pdm info && pdm info --env
PDM version:
  2.4.0
Python Interpreter:
  /Users/capitanu/Projects/Testing/pdm-test/.venv/bin/python (3.11)
Project Root:
  /Users/capitanu/Projects/Testing/pdm-test
Project Packages:
  None
{
  "implementation_name": "cpython",
  "implementation_version": "3.11.1",
  "os_name": "posix",
  "platform_machine": "arm64",
  "platform_release": "21.6.0",
  "platform_system": "Darwin",
  "platform_version": "Darwin Kernel Version 21.6.0: Sun Nov  6 23:31:13 PST 2022; root:xnu-8020.240.14~1/RELEASE_ARM64_T6000",
  "python_full_version": "3.11.1",
  "platform_python_implementation": "CPython",
  "python_version": "3.11",
  "sys_platform": "darwin"
}
@borice borice added the 🐛 bug Something isn't working label Jan 20, 2023
@vintprox
Copy link

vintprox commented Apr 3, 2023

Something related to CandidateNotFound error:

Adding packages to default dependencies: pywin32
🔒 Lock successful
Changes are written to pdm.lock.
Changes are written to pyproject.toml.
Synchronizing working set with lock file: 1 to add, 0 to update, 0 to remove

  ✖ Install pywin32 306 failed
Retry failed jobs
  ✖ Install pywin32 306 failed

ERRORS:
add pywin32 failed:
Traceback (most recent call last):
  File "/usr/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File 
"/home/vintprox/testrepo/.pyprojectx/venvs/pdm-b5d49143725009c57e5a67a3ece6e672-py3.10/lib/python3.10/site-packages/pdm/installers/synchroni
zers.py", line 233, in install_candidate
    self.manager.install(can)
  File 
"/home/vintprox/testrepo/.pyprojectx/venvs/pdm-b5d49143725009c57e5a67a3ece6e672-py3.10/lib/python3.10/site-packages/pdm/installers/manager.p
y", line 33, in install
    installer(str(prepared.build()), self.environment, prepared.direct_url())
  File 
"/home/vintprox/testrepo/.pyprojectx/venvs/pdm-b5d49143725009c57e5a67a3ece6e672-py3.10/lib/python3.10/site-packages/pdm/models/candidates.py
", line 360, in build
    self.obtain(allow_all=False)
  File 
"/home/vintprox/testrepo/.pyprojectx/venvs/pdm-b5d49143725009c57e5a67a3ece6e672-py3.10/lib/python3.10/site-packages/pdm/models/candidates.py
", line 403, in obtain
    raise CandidateNotFound(
pdm.exceptions.CandidateNotFound: No candidate is found for `pywin32` that matches the environment or hashes

See /tmp/pdm-install-i7lr0nud.log for detailed debug log.
[InstallationError]: Some package operations are not complete yet
Add '-v' to see the detailed traceback

Understandably, it fails to install a library which was clearly made for another operating system, but such huge stderr doesn't fit the use case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants