[Bf-committers] Python interpreter oddities

Beau Hargis bf-committers@blender.org
Tue, 6 May 2003 02:24:48 -0700 (PDT)


I have been attempting to mess around with the python scripting some and 
could not get anything to work until I found out that there seems to be a 
problem with the paths and prefix the interpreter is setting itself up 
with at initialization, so it could not load any modules from the system 
that were not previously frozen (like 'os' and 'struct'). It seems to also 
ignore the PYTHONHOME and PYTHONPATH environment variables. I found the 
problem (at least on my machine) with this little tidbit of code:

# begin
import sys
print "prefix: " , sys.prefix
print "sys.path: "
for p in sys.path:
	print " " , p
#end

I ran it from python installed on the machine and got this:

prefix:  /usr
sys.path: 
  
  /usr/lib/python2.2
  /usr/lib/python2.2/plat-linux-i386
  /usr/lib/python2.2/lib-tk
  /usr/lib/python2.2/lib-dynload
  /usr/lib/python2.2/site-packages
  /usr/lib/python2.2/site-packages/Numeric

which is correct. And now from blender: 

Prefix:  /usr/lib/python2.2
Paths: 
   /usr/lib/python2.2/lib/python2.2/
   /usr/lib/python2.2/lib/python2.2/plat-linux-i386
   /usr/lib/python2.2/lib/python2.2/lib-tk
   /usr/lib/python2.2/lib/python2.2/lib-dynload

which is wrong, and the reason why it could not load any of the modules
installed on the system. I dont know how it got set to this or why.  
PYTHONPREFIX should be /usr not /usr/lib/python2.2. You can see how it
created the paths (which are directoriies that do not exist). 
/usr/lib/python2.2 should be sys.path[0], (sys.prefix + /lib/python2.2).

I don't know if it's happening in the freezing process or at interp 
initialization time. There are 3 or 4 different directories and 
collections of files that all want to be the Blender Python interface and 
I don't know which one is the real one so I am at a loss to figure it out.

Is this just a problem on my system for some reason? Does the freezing 
really have to take place given that Blender is now opensource and can be 
repackaged more freely? Is it unreasonable to expect python to be 
installed or to have the user install python 2.0+? 


-- 

-------------------------
&${\eval(unpack("u*",'F(\'-U8GMP<FEN=")<;F)E875H7$!S8VAW;V]G;&4N;W)G7&XB.WT`'))}