-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pip shouldn't use __main__.py
in its warnings when invoked as a module
#6576
Comments
__main__.py
in its warnings__main__.py
in its warnings when invoked as a module
Hmm, I don't think that's vanilla pip. @torsava @stratakis @hroncok Is this a patch applied by Fedora? |
It's the sys.argv[0] value that isn't very good in this case. If you know how to get the actual command line invocation, that would be great. Of course, we could detect |
@pradyunsg do you mind if we finish this conversation here? |
Like this? # Check whether we have root privileges and aren't in venv/virtualenv
if os.getuid() == 0 and not is_venv():
command = path.basename(sys.argv[0])
if command == "__main__.py":
command = path.basename(sys.executable) + " -m pip"
logger.warning(
"WARNING: Running pip install with root privileges is "
"generally not a good idea. Try `%s install --user` instead."
% command
) |
@hroncok getting the real (full) command line in Python is PITA and needs a lot of hacks. I've been meaning to release a dist with that to PyPI but never got to do it... |
Nope. :) |
@webknjaz Please do close this once this is resolved. :) (or @ me since I'm unsubscribing for now) |
I'm okay with closing it right away if @hroncok has a better place for tracking it. I just wanted to report it upstream but it doesn't actually affect me :) |
I'll do a PR in Fedora and post a link here. Unfortunately I won't get to it before Monday. |
@hroncok should I keep this open? |
Whatever you prefer. |
Okay, closing then. |
Environment
Description
In its warning, Pip refers to mysterious
__main__.py
and I think that most of the entry-level users don't know what that is.It would be more friendly to avoid using that name.
Expected behavior
WARNING: Running pip install with root privileges is generally not a good idea. Try `pip install --user` instead.
or (better)
WARNING: Running pip install with root privileges is generally not a good idea. Try `python3.7 -m pip install --user` instead.
How to Reproduce
sudo python -m pip install {{ pkg }}
Output
The text was updated successfully, but these errors were encountered: