Page MenuHome

site not automatically imported when using external python package
Closed, ResolvedPublic


Since blender is using Python 3.2, it does not import site automatically anymore. While this is probably acceptable when using the bundled python package (because the bundled package is not registered at system level and thus its site-packages directory is not visible to external installers), this is not justified if the bundle python package is not present: blender looks in this case for a system Python package, which, if it exists, is properly setup to import site. Not importing site means that external packages that might have been installed by the user will not be visible from python scripts.

The reason why site is not imported is explained in the code:

/* Python 3.2 now looks for '2.xx/python/include/python3.2d/pyconfig.h' to
* parse from the 'sysconfig' module which is used by 'site',
* so for now disable site. alternatively we could copy the file. */
Py_NoSiteFlag = 1;

The attached patch (author: Sjoerd de Vries) fixes this problem: Py_NoSiteFlag is not set when the bundle python package is not found to give a change

Event Timeline

committed r46766. with some minor changes.

Campbell Barton (campbellbarton) changed the task status from Unknown Status to Resolved.May 18 2012, 12:20 PM