This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: site.USER_SITE is None for Windows embeddable Python 3.6
Type: behavior Stage: resolved
Components: Windows Versions: Python 3.6
process
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 2022-04-11 14:58 by admin. 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
    'C:\\Users\\Brecht\\AppData\\Roaming\\Python\\Python35\\site-packages'
    >>>

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 https://www.nuget.org/packages?q=publisher%3A%22Python+Software+Foundation%22
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: https://github.com/pypa/pip/issues/4437.

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 sitecustomize.py 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.
History
Date User Action Args
2022-04-11 14:58:44adminsetgithub: 74180
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