-
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
AttributeError while installing package from PythonShell #4598
Comments
Thanks for filing this issue! Using pip by importing is not a supported way of using pip. The only supported way of using pip is to run it as a command line program. That is, opening cmd.exe and using pip as follows:
|
Also, this is likely fixed in the development version of pip. We changed this in #4486 |
Two questions: I use pip in my python scripts to install packages on systems for our developers, so they don't have to handle this stuff for themselves. So the alternative would be to use |
Simply because the code wasn't written for that purpose, we never documented any guarantees for the internal APIs, and we don't have the time to support people using the internal API. Specifically, if we documented a supported API, we would have to ensure that any changes we made to the internals of pip maintained compatibility for the documented API.
No more so than calling git using Having said all of the above, realistically, using |
This would be a duplicate of #3356... |
That clarifies that. |
@MarKett In fact @pradyunsg pointed out the real issue. It's still not supported usage, but it's not hard to fix, so I've just pushed a fix for it so the problem should be resolved in the next version of pip. Thanks for flagging the issue! |
Description:
Cause:
In some cases
sys.__stdout__
can beNone
, as noted here: https://docs.python.org/3/library/sys.htmlpip does not check this in:
Python36\lib\site-packages\pip\compat\__init__.py
Line: 73
It tries to call
sys.__stdout__.encoding
and obviously failsSolution:
Implement a check for
sys.__stdout__ != None
before trying to access it.What I've run:
StackTrace:
The text was updated successfully, but these errors were encountered: