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

Unhelpful error message when python version requirement is not met #1282

Closed
sumau opened this issue Dec 31, 2020 · 6 comments
Closed

Unhelpful error message when python version requirement is not met #1282

sumau opened this issue Dec 31, 2020 · 6 comments
Labels
support User support

Comments

@sumau
Copy link

sumau commented Dec 31, 2020

What's the problem this feature will solve?

When I try to install a package that requires a different python version to the default / installed python version, pipenv prints an error message that is unhelpful. I raised on ticket on pipenv (pypa/pipenv#4573) but I was told this was an issue in pip-tools.

For example when attempting to install dataclasses (which requires python 3.6) in python 3.8 environment :

$ pipenv install dataclasses --python 3.8

Creating a Pipfile for this project…
Installing dataclasses…
Looking in indexes: https://pypi.python.org/simple
Collecting dataclasses
Using cached dataclasses-0.6-py3-none-any.whl (14 kB)
Installing collected packages: dataclasses
Successfully installed dataclasses-0.6

Adding dataclasses to Pipfile's [packages]…
Pipfile.lock not found, creating…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
Updated Pipfile.lock (3b8787)!
Installing dependencies from Pipfile.lock (3b8787)…
An error occurred while installing dataclasses==0.8! Will try again.
🐍 ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 1/1 — 00:00:01
Installing initially–failed dependencies…
Looking in indexes: https://pypi.python.org/simple00

ERROR: Could not find a version that satisfies the requirement dataclasses==0.8 (from -r /tmp/pipenv-iaa6wplp-requirements/pipenv-0xs63m0r-requirement.txt (line 1)) (from versions: 0.1, 0.2, 0.3, 0.4, 0.5, 0.6)
ERROR: No matching distribution found for dataclasses==0.8 (from -r /tmp/pipenv-iaa6wplp-requirements/pipenv-0xs63m0r-requirement.txt (line 1))

Describe the solution you'd like

Print useful error message when python requirement not met, ideally which python version is compatible

Alternative Solutions

Not sure

Additional context

OS: Ubuntu WSL1
Pipenv version: '2020.11.15'

@jdufresne
Copy link
Member

Can you reproduce without involving pipenv?

@sumau
Copy link
Author

sumau commented Dec 31, 2020

I couldn't reproduce the error and when I try to use venv+pyenv+piptools to install dataclasses in a python 3.5 environment, the install is successful but the import fails with another unhelpful error message (see below).

$pyenv local 3.5.5
$python3 -m venv venv
$source venv/bin/activate
$pip install pip-tools
$cat requirements.in

dataclasses

$pip-compile requirements.in
$pip-sync requirements.txt

Collecting dataclasses
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Downloading https://files.pythonhosted.org/packages/26/2f/1095cdc2868052dd1e64520f7c0d5c8c550ad297e944e641dbf1ffbb9a5d/dataclasses-0.6-py3-none-any.whl
Installing collected packages: dataclasses
Successfully installed dataclasses-0.6

$python
'>import dataclasses

Traceback (most recent call last):
File "", line 1, in
File "/home/souma/ex_4/example-project/lib/python3.5/site-packages/dataclasses.py", line 246
f'name={self.name!r},'
^
SyntaxError: invalid syntax

@jdufresne
Copy link
Member

The dataclasses project requires Python 3.6, so it is not compatible with your environment.

It is up to them to properly declare that metadata and is not the fault of pip-tools.

@jdufresne jdufresne added the support User support label Dec 31, 2020
@sumau
Copy link
Author

sumau commented Jan 1, 2021

My bad - dataclasses does declare that it requires python3.6 in setup.py, but only in versions 0.7 and above. Hence version 0.6 gets installed by default when I try to install dataclasses in a python3.5 environment. However if I specify dataclasses==0.8 in the requirements.ini, pip-compile fails with the following error message (I've removed the traceback for clarity):

ERROR: Could not find a version that satisfies the requirement dataclasses==0.8 (from -r requirements.in (line 1)) (from versions: 0.1, 0.2, 0.3, 0.4, 0.5, 0.6)
pip._internal.exceptions.DistributionNotFound: No matching distribution found for dataclasses==0.8 (from -r requirements.in (line 1))

Which matches the error message I received with pipenv.

Was I reading the error message incorrectly and "matching distribution" means "matching python version"? Is the error message coming from pip instead of pip-tools? Happy to close if you think there's nothing pip-tools can do :-)

@atugushev
Copy link
Member

Is the error message coming from pip instead of pip-tools?

Correct, that's pip's message. It might be a good idea to raise an issue on pip's tracker to improve UX in this particular case.

$ python -V
Python 3.5.10

$ pip install dataclasses==0.8
ERROR: Could not find a version that satisfies the requirement dataclasses==0.8
ERROR: No matching distribution found for dataclasses==0.8

@sumau
Copy link
Author

sumau commented Jan 2, 2021

Did some digging and it has already been raised an issue with pip so closing this ticket - thanks for the quick response :-)

pypa/pip#8831

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
support User support
Projects
None yet
Development

No branches or pull requests

3 participants