Adding Python interpreter info to "pip install"

The goal of this idea is to make it easier to find out when someone has installed packages for the wrong python installation. I'm coming across quite a few StackOverflow posts and emails where beginners are using pip to install a package, but then finding they can't import it because they have multiple python installations and used the wrong pip. For example, this guy has this problem: https://stackoverflow.com/questions/37662012/which-pip-is-with-which-python I'd propose adding a simple line to the output of "pip install" that changes this: user@user:~$ pip3 install pyperclip Collecting pyperclip Installing collected packages: pyperclip Successfully installed pyperclip-1.6.2 ...to something like this: user@user:~$ pip3 install pyperclip Running pip for /usr/bin/python3 Collecting pyperclip Installing collected packages: pyperclip Successfully installed pyperclip-1.6.2 This way, when they copy/paste their output to StackOverflow, it'll be somewhat more obvious to their helper that they used pip for the wrong python installation. This info would also be useful for the output of "pip info", but that would break scripts that reads that output. Any thoughts? -Al

On Fri, Jul 20, 2018 at 10:45 AM, Al Sweigart <asweigart@gmail.com> wrote:
You can get some very useful information from "pip3 --version". As well as pip's own version, it tells you the version of Python that it's running under, AND what directory it's being run from. If you want to request that similar info be added to other commands, I would strongly recommend lifting the exact format of --version and using that. (I'm not sure what "pip info" is, btw. My pip doesn't seem to have that.) ChrisA

Sorry, I meant "pip list", rather than "pip info". I thought about the fact that "pip --version" provides this info, but 1) it provides the location of pip, not the python interpreter it installs packages for and 2) it would be an additional step for the question-asker to go through after posting the output of "pip install". It would be nice to display output that the question-asker can compare directly with the output of "which python". And I'd like to shorten the potential amount of back-and-forth before the helper can get the information they need. Additionally, while they could always just run "python -m pip install spam" but most tutorials tell them to run pip directly, so I still see the need for this. On Thu, Jul 19, 2018 at 5:50 PM, Chris Angelico <rosuav@gmail.com> wrote:

as it requires only a log, i think it is worth it as pip acts covertly meaning you don't see which pip is being used in a multi-py environment, yes you can have version pip info Abdur-Rahmaan Janhangeer https://github.com/Abdur-rahmaanJ Mauritius

On Thu, Jul 19, 2018 at 5:45 PM, Al Sweigart <asweigart@gmail.com> wrote:
This sounds like a great idea to me, but pip is developer separately from python itself, and I don't think the pip maintainers monitor python-ideas. I'd suggest filing a feature request on the pip tracker: https://github.com/pypa/pip/issues/new?template=feature-request.md -n -- Nathaniel J. Smith -- https://vorpus.org

`python -m site` and its docs may also be useful for troubleshooting end-user installations. A diagnostic script with e.g. these commands could also be helpful: which python which pip python -m site # sys.path, USER_SITE (pip --user) python -m pip --version
print((os.name, sys.platform, platform.system()))
https://docs.python.org/3/library/site.html """ The site module also provides a way to get the user directories from the command line: $ python3 -m site --user-site /home/user/.local/lib/python3.3/site-packages If it is called without arguments, it will print the contents of sys.path on the standard output, followed by the value of USER_BASE and whether the directory exists, then the same thing for USER_SITE, and finally the value of ENABLE_USER_SITE. --user-base Print the path to the user base directory. --user-site Print the path to the user site-packages directory. If both options are given, user base and user site will be printed (always in this order), separated by os.pathsep. If any option is given, the script will exit with one of these values: O if the user site-packages directory is enabled, 1 if it was disabled by the user, 2 if it is disabled for security reasons or by an administrator, and a value greater than 2 if there is an error. """ On Friday, July 20, 2018, Nathaniel Smith <njs@pobox.com> wrote:

On Fri, 20 Jul 2018, 09:52 Nathaniel Smith, <njs@pobox.com> wrote:
At least one (me) does lurk here. ;) I'd suggest filing a feature request on the pip tracker:
https://github.com/pypa/pip/issues/new?template=feature-request.md
I second this suggestion to file a feature request for this on the tracker. Additionally, you should also take a look to see if this has been filed already since I do remember having a discussion where this came. :) -- Pradyun

On 7/20/2018 12:21 AM, Nathaniel Smith wrote:
So have I. The solution is to run pip the way the core developers recommend, which is to explicitly run the version of python you want pip to install to. On Windows, py -x.y -m pip install somemod I have given that answer on SO and just gave it on python-list, thereby solving the users 2.7 versus 3.7 problem.
Definitely. -- Terry Jan Reedy

On Fri, Jul 20, 2018 at 10:45 AM, Al Sweigart <asweigart@gmail.com> wrote:
You can get some very useful information from "pip3 --version". As well as pip's own version, it tells you the version of Python that it's running under, AND what directory it's being run from. If you want to request that similar info be added to other commands, I would strongly recommend lifting the exact format of --version and using that. (I'm not sure what "pip info" is, btw. My pip doesn't seem to have that.) ChrisA

Sorry, I meant "pip list", rather than "pip info". I thought about the fact that "pip --version" provides this info, but 1) it provides the location of pip, not the python interpreter it installs packages for and 2) it would be an additional step for the question-asker to go through after posting the output of "pip install". It would be nice to display output that the question-asker can compare directly with the output of "which python". And I'd like to shorten the potential amount of back-and-forth before the helper can get the information they need. Additionally, while they could always just run "python -m pip install spam" but most tutorials tell them to run pip directly, so I still see the need for this. On Thu, Jul 19, 2018 at 5:50 PM, Chris Angelico <rosuav@gmail.com> wrote:

as it requires only a log, i think it is worth it as pip acts covertly meaning you don't see which pip is being used in a multi-py environment, yes you can have version pip info Abdur-Rahmaan Janhangeer https://github.com/Abdur-rahmaanJ Mauritius

On Thu, Jul 19, 2018 at 5:45 PM, Al Sweigart <asweigart@gmail.com> wrote:
This sounds like a great idea to me, but pip is developer separately from python itself, and I don't think the pip maintainers monitor python-ideas. I'd suggest filing a feature request on the pip tracker: https://github.com/pypa/pip/issues/new?template=feature-request.md -n -- Nathaniel J. Smith -- https://vorpus.org

`python -m site` and its docs may also be useful for troubleshooting end-user installations. A diagnostic script with e.g. these commands could also be helpful: which python which pip python -m site # sys.path, USER_SITE (pip --user) python -m pip --version
print((os.name, sys.platform, platform.system()))
https://docs.python.org/3/library/site.html """ The site module also provides a way to get the user directories from the command line: $ python3 -m site --user-site /home/user/.local/lib/python3.3/site-packages If it is called without arguments, it will print the contents of sys.path on the standard output, followed by the value of USER_BASE and whether the directory exists, then the same thing for USER_SITE, and finally the value of ENABLE_USER_SITE. --user-base Print the path to the user base directory. --user-site Print the path to the user site-packages directory. If both options are given, user base and user site will be printed (always in this order), separated by os.pathsep. If any option is given, the script will exit with one of these values: O if the user site-packages directory is enabled, 1 if it was disabled by the user, 2 if it is disabled for security reasons or by an administrator, and a value greater than 2 if there is an error. """ On Friday, July 20, 2018, Nathaniel Smith <njs@pobox.com> wrote:

On Fri, 20 Jul 2018, 09:52 Nathaniel Smith, <njs@pobox.com> wrote:
At least one (me) does lurk here. ;) I'd suggest filing a feature request on the pip tracker:
https://github.com/pypa/pip/issues/new?template=feature-request.md
I second this suggestion to file a feature request for this on the tracker. Additionally, you should also take a look to see if this has been filed already since I do remember having a discussion where this came. :) -- Pradyun

On 7/20/2018 12:21 AM, Nathaniel Smith wrote:
So have I. The solution is to run pip the way the core developers recommend, which is to explicitly run the version of python you want pip to install to. On Windows, py -x.y -m pip install somemod I have given that answer on SO and just gave it on python-list, thereby solving the users 2.7 versus 3.7 problem.
Definitely. -- Terry Jan Reedy
participants (8)
-
Abdur-Rahmaan Janhangeer
-
Al Sweigart
-
Chris Angelico
-
Nathaniel Smith
-
Pradyun Gedam
-
Terry Reedy
-
Thomas Jollans
-
Wes Turner