question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Pip will install Python3-only packages on Python2

See original GitHub issue
  • Pip version: 9.0.1
  • Python version: 2.7.3
  • Operating system: Debian GNU/Linux 8 on Docker (running Docker image python:2.7)

Description:

I’ve published a package on PyPI which only supports Python3, and I’m sure I’ve set the setup.py metadata to describe it as only Python3… but I’ve discovered that someone running Python2.7 can do pip install <my package> and Pip will happily install it.

Is this expected behaviour? Have I made a mistake in my project’s setup.py?

Reading some of the discussion on #3984

The over-specified version requirement thing is important. It’s way more irritating to have trouble installing a package that would work except it has incorrect metadata than to get a successful install of something that does not quite execute correctly.

… I’m not sure if this is a deliberate consequence of how version compatibility is checked?

What I’ve run:

$ docker run -it python:2.7 bash
root@aec4834958e1:/# pip --version
pip 9.0.1 from /usr/local/lib/python2.7/site-packages (python 2.7)
root@aec4834958e1:/# python --version
Python 2.7.13
root@aec4834958e1:/# cat /etc/issue
Debian GNU/Linux 8 \n \l

root@aec4834958e1:/# cd
root@aec4834958e1:~# pip install fang
Collecting fang
  Downloading fang-0.7.6.tar.gz
Building wheels for collected packages: fang
  Running setup.py bdist_wheel for fang ... done
  Stored in directory: /root/.cache/pip/wheels/b1/db/be/9d9370b32b6004b4ef5bba6a21d3e7da3e1443b97be6c1fd9e
Successfully built fang
Installing collected packages: fang
Successfully installed fang-0.7.6
root@aec4834958e1:~# python
Python 2.7.13 (default, Feb 28 2017, 22:13:47)
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import fang
>>> fang
<module 'fang' from '/usr/local/lib/python2.7/site-packages/fang/__init__.pyc'>

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
ncraikecommented, Aug 11, 2017

I may have been using Pip ≥ 9, but I likely still didn’t get the desired behaviour because my package (Fang) doesn’t yet use the python_requires option in its setup.py.

On Wed, 9 Aug 2017 12:37 pm Lucy He notifications@github.com wrote:

Which versions of pip starts to support python_requires? This post https://stackoverflow.com/questions/42238484/prevent-package-from-being-installed-on-old-python-versions/42792413#42792413 suggests it’s 9.0.0, but it looks like @ncraike https://github.com/ncraike was already using 9.0.1.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/pypa/pip/issues/4327#issuecomment-321359581, or mute the thread https://github.com/notifications/unsubscribe-auth/ABDtFS4ZZ_fdFsS6l9S8SvGS1XWuidTgks5sWgqGgaJpZM4MaFz0 .

0reactions
lucy-hcommented, Aug 9, 2017

Which versions of pip starts to support python_requires? This post suggests it’s 9.0.0, but it looks like @ncraike was already using 9.0.1.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Installing Packages - Python Packaging User Guide - Python.org
This section covers the basics of how to install Python packages. ... This section describes the steps to follow before installing other Python...
Read more >
Can pip (python2) and pip3 (python3) coexist? - Stack Overflow
1 Answer 1 · After installing python 3's pip (and having it overwrite python 2's pip), using the --force flag combined with the...
Read more >
How to install and use Pip3 - ActiveState
pip3 is the official package manager and pip command for Python 3. It enables the installation and management of third party software packages...
Read more >
How to Install Python PIP on Windows, Mac, and Linux
PIP is an acronym that stands for “PIP Installs Packages” or “Preferred Installer Program.” It's a package manager for Python that lets you ......
Read more >
How to Install a Package in Python using PIP - Data to Fish
(5) Locate your Python Scripts path. The Scripts folder can be found within the Python application folder, where you originally installed Python ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found