import os

Scripting in Blender with Python, and working on the API

Moderators: jesterKing, stiv

millirad
Posts: 11
Joined: Mon Feb 10, 2003 12:24 am

import os

Postby millirad » Sun Apr 20, 2003 10:44 pm

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?

ray_theray
Posts: 49
Joined: Wed Oct 16, 2002 3:05 am
Location: NM, US
Contact:

Postby ray_theray » Sun Apr 20, 2003 10:58 pm

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

millirad
Posts: 11
Joined: Mon Feb 10, 2003 12:24 am

Where is PythonPath set?

Postby millirad » Mon Apr 21, 2003 2:05 am

Where do I set PythonPath?

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

millirad
Posts: 11
Joined: Mon Feb 10, 2003 12:24 am

python path

Postby millirad » Mon Apr 21, 2003 2:19 am

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.

ray_theray
Posts: 49
Joined: Wed Oct 16, 2002 3:05 am
Location: NM, US
Contact:

Postby ray_theray » Mon Apr 21, 2003 4:43 am

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: Select all

$ 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: Select all

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

millirad
Posts: 11
Joined: Mon Feb 10, 2003 12:24 am

Fixed

Postby millirad » Mon Apr 21, 2003 5:41 am

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!

sscherer
Posts: 3
Joined: Sun Apr 27, 2003 11:02 pm

Postby sscherer » Sun Apr 27, 2003 11:08 pm

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')


Return to “Python”

Who is online

Users browsing this forum: No registered users and 2 guests