Linux: import problems

I am having lots of problems trying to import certain modules when using python from Blender. I can’t figure out at all what the problem is, the usual python path fix doesn’t work. Modules that are used often in scripts like string or math are imported without problems, but some ‘exotic’ modules fail to import.
All of these produce import errors:
StringIO, cPickle, array, errno, fnmatch
and I’m sure there are others too I didn’t try yet. These are also causing trouble when trying to run Dynamica in Linux, and also now for the Lightflow script. I can create a workaround, but I’d rather be able to use everything as normal. Everything does work normally when using python by itself, but not from Blender.
I am a Linux newbie, so I might have done something wrong myself, I actually installed Python2.0 from my home directory for instance, although as far as I understand that shouldn’t really be a problem. Python2.1 was already installed by default (SuSe7.3), if I try to set the path to that, I get errors (in Blender) like ‘Py_NotImplementedstruct’ or something similar, and other errors that look like compiler errors (‘unreferenced variable’).
Anyone has any idea’s at all?
Incidentally, how do I uninstall python2.0? Do I really have to manually remove everything? (no ‘make uninstall’)

Please provide an example script and the exact error
message from the console when you have these kinds
of problems – they really help in trouble shooting.

As an experiment, I tried to import cPickle into blender
– here is what happened and how I overcame the prob’s:

  1. ‘import cPickle’ says module not found.

  2. I type ‘locate cPickle’ (you probably have findutils
    installed so this should work). This returns the following:
    /usr/lib/python1.5/lib-dynload/cPickle.so
    /usr/lib/python2.0/lib-dynload/cPickle.so
    /usr/lib/python2.1/lib-dynload/cPickle.so
    /usr/share/doc/python1.5/html/lib/module-cPickle.html
    /usr/share/doc/python2.1/html/lib/module-cPickle.html

  3. I append ‘/usr/lib/python2.1/lib-dynload’
    to my PYTHONPATH (make sure to re-source
    the file you change this in).

  4. ‘import cPickle’ now gives:
    PYTHON SCRIPT ERROR:
    Traceback (most recent call last):
    File “Text”, line 1, in ?
    ImportError: /usr/lib/python2.1/lib-dynload/cPickle.so: undefined symbol: PyInstance_NewRaw

  5. I append ‘/usr/lib/python2.0/lib-dynload’
    to my PYTHONPATH

  6. ‘import cPickle’ now gives:
    I love you Hos, you big stud!

Well OK, that didn’t really happen, but it imported successfully
and here is the output from ‘print dir(cPickle)’ as proof:
[‘BadPickleGet’, ‘PickleError’, ‘Pickler’, ‘PicklingError’, ‘UnpickleableError’, ‘Unpickler’, ‘UnpicklingError’, ‘builtins’, ‘doc’, ‘file’, ‘name’, ‘version’, ‘compatible_formats’, ‘dump’, ‘dumps’, ‘format_version’, ‘load’, ‘loads’]

So it looks like cPickle works in Python2.0, but not in
Python2.1 (on my system anyways).

As for uninstalling, you can try ‘make uninstall’ (some
makefiles suport this). If it is installed locally in your
account then you can probably just delete the directory
it’s installed to. If these options are unappealing or
don’t work, then you are going to have to hunt
down the installed files and delete them manually.
To this end, the ‘find’ command is your friend and
you can find all the files that were created within
a certain time span, e.g.:

find /home/eeshlo -ctime +5 -ctime -15
(finds all files in the directory tree under
/home/eeshlo that were created within
5 and 15 hours ago)
see ‘info find’ for more details.

Of course, if you installed python from your
distributions packages all of this is moot.

Regards,
Chris

P.S. I am in the Alpha tester list for Dynamica
(although I haven’t actually taken the time to
install it yet). If there is anything specific you
want me to test out under linux, just let me know.

P.P.S. Crap! There goes my lunch hour!

Thanks Chris for spending the time to explain everything so clearly, but unfortunately the solution was something else. Of course after having spend three months struggling with this (I always like to try doing it by myself), of course shortly after posting this question I found out what the problem was. Like I said the path was not the problem, but for some reason all these modules were compiled but not installed at all. So I had to change the setup file and re-install python2.0 to force the modules being installed as shared. Now finally everything works as it should, but it is a mystery to me why it wasn’t installed by default in the first place. Although everything works now, I’m wondering if other users are going to have the same problems with the LF script. I’m sorry you had to waste your lunch hour for this…

hi eeshlo
i’m not a python devel and no time to learn for now :frowning: mybe on holiday
i got an error with your 10 april LF export script (on suse 7.3)
and not with the other one on export the same scene.
Cannot post the error now but i’ll post tomorrow
if you are interested, this is the scene
http://www.kino3d.com/blender/IMG/art17-2.jpg
Your script it’s really great

Kino

hi
solved, sorry to bother you.
now i can export my bugs :smiley:

Ciao
Kino