packaging-problems icon indicating copy to clipboard operation
packaging-problems copied to clipboard

What happens when you try to install an incompatible package?

Open hickford opened this issue 11 years ago • 5 comments

What happens when you try to install a package which happens not to be compatible with your Python version? I'm sure several thousand people do this every day, either because they are ignorant of the incompatibility, or youthfully optimistic. Even if PyPI and every project's documentation were explicit about compatibilities, it would still happen, so it's worth considering the behaviour.

Ideally, you would be shown an accurate and helpful message explaining the problem and how you might fix it. Perhaps:

pip install mechanize

The package 'mechanize' is not compatible with the version of Python (3.4) that you are using. It is compatible with Pythons 2.6, 2.7.

In reality, the outcome is wildly variable, depending on the package. There are two classes of outcomes:

Installation succeeds, but import fails later

This is particularly unhelpful, because it appears as if everything is fine. That's until the user later tries to import the module. The error then is rarely informative, typically it's a SyntaxError.

Installation fails

It's right that installation should fail, but the particular error message may or may not make it clear why. On Python 3.4, pip install legit shows an especially misleading message:

print "unable to find py2exe"

Read naively, that suggests the user is at fault and might be able to fix the problem by installing an app called py2exe.

hickford avatar Jun 04 '14 22:06 hickford

Yea, this is totally a thing. I think Metadata 2.0 provides a field that projects can use to declare what versions of Python they are compatible with.

dstufft avatar Jun 04 '14 23:06 dstufft

Course we don't use it yet, nor does anything really, but in theory!

dstufft avatar Jun 04 '14 23:06 dstufft

Right, handling this better is the goal of the python.constraints extension in PEP 459 (I really should get the latest drafts of everything up on python.org...)

ncoghlan avatar Jun 05 '14 00:06 ncoghlan

In the meantime: https://bitbucket.org/pypa/pypi-metadata-formats/src/default/standard-metadata-extensions.rst

ncoghlan avatar Jun 05 '14 00:06 ncoghlan

We have Requires-Python now, even if it has some uncertainty about upper constraints: https://discuss.python.org/t/requires-python-upper-limits/12663

merwok avatar Feb 11 '25 13:02 merwok