Previous Thread  Next Thread

chat icon import os

millirad

Posted: Sun Apr 20, 2003 9:44 pm
Joined: 10 Feb 2003
Posts: 11
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?
Reply with quote


ray_theray

Posted: Sun Apr 20, 2003 9:58 pm
Joined: 16 Oct 2002
Posts: 47
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).
_________________
-ray_theray
Reply with quote


millirad

Posted: Mon Apr 21, 2003 1:05 am
Joined: 10 Feb 2003
Posts: 11
Where do I set PythonPath?

Is this and environment variable or is it in a config file?
Reply with quote


millirad

Posted: Mon Apr 21, 2003 1:19 am
Joined: 10 Feb 2003
Posts: 11
I have PYTHONPATH as an enviromnment variable for python.
Is that what you mean?

It's set and pointing to my python directory.
/usr/lib/python<version>

'import os' still doesnt work.
Reply with quote


ray_theray

Posted: Mon Apr 21, 2003 3:43 am
Joined: 16 Oct 2002
Posts: 47
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:
Code:
$ 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
Code:
export PYTHONPATH=[insert the paths from above]


If you're still having trouble, look here:
http://www.elysiun.com/forum/viewtopic.php?t=7723

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).
_________________
-ray_theray
Reply with quote


millirad

Posted: Mon Apr 21, 2003 4:41 am
Joined: 10 Feb 2003
Posts: 11
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
my goal.

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!
Reply with quote


sscherer

Posted: Sun Apr 27, 2003 10:08 pm
Joined: 27 Apr 2003
Posts: 3
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:

>>import sys
>>sys.path.append('c:\\blender')
Reply with quote


 
Jump to:  
Powered by phpBB © 2001, 2005 phpBB Group