-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Importing pip crashes when site.USER_SITE is None #4437
Comments
While I agree that pip should handle a value of If you have a use case for running pip from the embeddable distribution, then you should probably describe it in more detail. |
My application, rinohtype manages optional dependencies such as fonts using Python packages on PyPI. Here's the list of fonts that are currently available, for example. When a specific font is referenced in a style sheet, rinohtype attempts to install it automatically from PyPI using pip. In the future, I would also like to use pip to allow the stand-alone rinohtype distribution to update itself. In that case the embedded Python is not updated, but the rinohtype package is. |
Hmm, so in effect you're using PyPI as your application's plugin repository. I don't know whether that's something we'd consider to be a reasonable use case, but thanks for the clarification. Let's see what the other @pypa/pip-committers think. |
I should note that as I stated, I agree pip should handle the lack of Note the following comment from the documentation (https://docs.python.org/3.6/using/windows.html#embedded-distribution):
|
Indeed, And thanks for the pointer to the documentation. That's good to remember. |
FWIW, one of the teams I work with is also considering using PyPI as essentially a (public) plugin repository like this, and will eventually distribute using the embeddable distro. It actually looks like this would be an issue whenever you run # Prevent extending of sys.path when python was started with -S and
# site is imported later.
if not sys.flags.no_site:
main() So if pip is going to import |
@pfmoore It was also added to 2.7, so it may be available in all supported Python versions. |
Weird. I'm getting incomprehensible failures in CI ("module 'site' has no attribute 'getusersitepackages'") I can't reproduce this locally outside of pip. Can anyone suggest what might be going wrong? Do we mock the site module in our tests or something like that? |
Virtual environments use a site.py copied from like Python 2.4 and randomly updated with new features. I bet it needs updated too.
…Sent from my iPhone
On Apr 12, 2017, at 2:23 PM, Paul Moore ***@***.***> wrote:
Weird. I'm getting incomprehensible failures in CI ("module 'site' has no attribute 'getusersitepackages'") I can't reproduce this locally outside of pip. Can anyone suggest what might be going wrong? Do we mock the site module in our tests or something like that?
—
You are receiving this because you are on a team that was mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Oh lovely. Well I'm not going down that rabbit hole now. I can do a check for the attribute and use it if present. That's probably better anyway. Thanks for that! |
embedded python - love it |
@pfmoore I can confirm the PR fixes my problem. Thanks! |
Thanks. I've merged the PR so it should be in the next release of pip. |
Closed by #4442 |
In the embeddable Python distribution for Windows,
site.USER_SITE
isNone
by design since 3.6.0. Pip does not handle this case and crashes on import:See also this CPython ticket.
The text was updated successfully, but these errors were encountered: