What happens when you try to install an incompatible package?
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 mechanizeThe 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.
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.
Course we don't use it yet, nor does anything really, but in theory!
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...)
In the meantime: https://bitbucket.org/pypa/pypi-metadata-formats/src/default/standard-metadata-extensions.rst
We have Requires-Python now, even if it has some uncertainty about upper constraints: https://discuss.python.org/t/requires-python-upper-limits/12663