pypa / pip

The Python package installer
https://pip.pypa.io/
MIT License
9.51k stars 3.02k forks source link

Silent install: Add --yes to pip install #9750

Open thisisreallife opened 3 years ago

thisisreallife commented 3 years ago

pip version

0.21

Python version

3.6

OS

macos

Additional information

No response

Description

Sometimes pip ask user to type y/n into terminal , determining whether to go further. -y/--yes means automatically yes. However, in the new version of pip, it says no such option: -y

Expected behavior

No response

How to Reproduce

pip install python-louvain -y

Output

no such option -y

Code of Conduct

uranusjr commented 3 years ago

Does pip install ever ask a y/n question? pip uninstall does, and it indeed has a -y option. Accepting -y when no y/n question is asked sounds wrong to me.

thisisreallife commented 3 years ago

Does pip install ever ask a y/n question? pip uninstall does, and it indeed has a -y option. Accepting -y when no y/n question is asked sounds wrong to me.

When we try to pip install some_package, system may try to figure out the dependency of packages. In that situation, pip may want to uninstall/update some_other_packages and then proceed the original pip install some_package, which may ask user to type y/n to proceed the progress or stop from there.

uranusjr commented 3 years ago

In that situation, pip may want to uninstall/update some_other_packages and then proceed the original pip install some_package

I don’t think it does? pip intentionally uninstalls packages without user prompts in this situation (which some people consider problematic, see #9646).

boris-donchev commented 1 year ago

Does pip install ever ask a y/n question? pip uninstall does, and it indeed has a -y option. Accepting -y when no y/n question is asked sounds wrong to me.

When you add a package outside of PyPi (e.g. bitbucket.org) it does. If the host is not in the known_hosts for example

pradyunsg commented 1 year ago

Do you have an example?

notatallshaw commented 1 year ago

Do you have an example?

I came across this the other day, you can just see where ask is referenced: https://github.com/pypa/pip/blob/22.3.1/src/pip/_internal/utils/misc.py#L186

I believe boris-donchev is referring to this specific case: https://github.com/pypa/pip/blob/22.3.1/src/pip/_internal/network/auth.py#L243 which can come up any time a 401 responds from a network request.

IMO a better solution would be to remove ask, and replace each instance where it's used with a specific CLI flag to accept it otherwise fail.

Conda which provides global -y and -n flags does this because it is expected by default there will be user interaction. The problem with providing -y though when you're automating conda is you miss cases where a prompt comes up that you would rather error on.

But that's my two cents.