Title: site.USER_SITE is None for Windows embeddable Python 3.6
Type: behavior Stage: resolved
Components: Windows Versions: Python 3.6
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: brechtm, paul.moore, steve.dower, tim.golden, zach.ware
Priority: normal Keywords:

Created on 2017-04-05 10:36 by brechtm, last changed 2017-04-12 17:22 by steve.dower. This issue is now closed.

Messages (5)
msg291174 - (view) Author: Brecht Machiels (brechtm) Date: 2017-04-05 10:36
Previous versions of the embeddable Python:

    Python 3.5.3 (v3.5.3:1880cb95a742, Jan 16 2017, 16:02:32) [MSC v.1900 64 bit (AMD64)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import site
    >>> site.USER_SITE

Version 3.6.0 and 3.6.1, both win32 and amd64:

    Python 3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 17:54:52) [MSC v.1900 32 bit (Intel)] on win32
    >>> import site
    >>> site.USER_SITE

 This causes problems when importing pip for example.
msg291519 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2017-04-11 22:38
This is by design - the embeddable Python is meant to exclude anything relating to the current user by default.

If you're looking for a lightweight Python install that you can use for things like building or managing packages, you may be interested in the Nuget packages - see
msg291526 - (view) Author: Brecht Machiels (brechtm) Date: 2017-04-12 07:45
I see. In that case I think pip should be able to handle the case when site.USER_SITE is None. I have created a ticket here:

I am using the embeddable Python what's it intended for, to make a self-contained distribution of my application (using pynsist). I'm using pip to install optional resources (fonts).
msg291564 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2017-04-12 17:13
Yes, fixing pip in this case is the right approach.

Since you're going to be including a copy of pip with your application, you can also just patch that yourself to get going while the pip team decides how to go from here. Or you could add a file (which will only be imported if you have "import site" in your ._pth file) that sets site.USER_SITE to something so that pip does not crash.
msg291566 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2017-04-12 17:22
Actually, I suspect you're not importing site on startup at all (which is great for performance), but that means that site.main() is not being run. I'll post more details on the pip bug.
Date User Action Args
2017-04-12 17:22:52steve.dowersetmessages: + msg291566
2017-04-12 17:13:44steve.dowersetmessages: + msg291564
2017-04-12 07:45:33brechtmsetmessages: + msg291526
2017-04-11 22:38:10steve.dowersetstatus: open -> closed
resolution: not a bug
messages: + msg291519

stage: resolved
2017-04-05 10:36:22brechtmcreate