It would be a real help making tools for blender if
we could ' import os' and open pipes.
Does blender actually use real python or is the language in blender
just a built-in parser that someone fudged?
I believe Blender contains a basic Python interpreter (enough to process variable assignments, basic math and coercion, things of that kind - without the standard Python modules) and at least two of its own modules - Blender and GameLogic. If you have Python installed and the PythonPath set correctly, however, Blender uses your full Python installation and can import all of Python's built in modules (such as os, sys, popen2, all of those).
Where do I set PythonPath?
Is this and environment variable or is it in a config file?
I have PYTHONPATH as an enviromnment variable for python.
Is that what you mean?
It's set and pointing to my python directory.
'import os' still doesnt work.
Yes, sorry I was unclear about that. I think, though, the Pythonpath needs to point to some more directories within the main python directory.
To find out exactly what you need, start up python:
|$ python (press Enter)
>>> import sys (Enter)
>>> print sys.path (Enter)
Now it should tell you exactly what needs to be in the pythonpath. Exit Python (CTRL-Z, I believe) and then do
|export PYTHONPATH=[insert the paths from above] |
If you're still having trouble, look here:
EDIT: I just now noticed you solved the problem. You can probably stick the "export PYTHONPATH" command in a startup script (check the link above for more info).
Thanks for your help.
I managed to figure out what was wrong .
The environment variable doesnt seem to get set
unless I set it for the session. So I just put it in a bash script and modified my icon
to point to the script instead of blender.
Now I can use 'popen', and 'system' which is
I am starting development of a realtime skeletal animator where
the physics can be recorded by dragging the model nodes around
like a mariennette.
This will lend itself to reading positions from sensors so that actual
motion can be recorded.
There are also things like realistic particle hair and other physics that
C/C++ is a bit more effective at (faster) than python.
wish me luck.....heh!
Steve Holden wrote a great book on Python called Python Web Programming. The first chapter describes many, many cool things about Python, including how to change/append directories to your PYTHONPATH variable. On Windows, this works for me: