Error with Chicken R81

I just got started using Panda3D, and am trying to use Blender to create some models. I installed Chicken R81, but when I try to use it, it gives me this configuration error:

“egg2bam” returned 32512. Perhaps your PATH environment variable is not properly set

So I opened a terminal window to check if egg2bam will run. It returns the usage information, indicating that it was found. egg-optchar and pview both work as well. I was going to just start reading through the Chicken scripts and see what I could find, but I figured that somebody here would know what’s going on.

Thanks all.

Not sure - no idea what that error code means, or why it would be thrown. The error is generated by the code that, as it indicates, tests if the Panda commands it needs are available, and it fails due to expecting a zero as a response rather than that value. Command not found should give a -1, hence my confusion.

Couple of basic questions: What operating system are you running, also, if Linux, what is your default shell (In case it is something that isn’t normal - the os.system() function, which is used in this case, depends on this.).

I’m running Mac OS 10.5.8. xelavelobos seems to have had the same problem on the page 9 of “Chicken, an Egg exporter for Blender [V1.0 (final) out!]” but no solution was found. He got a fresh install of Windows XP, Panda3D and Blender, and it just worked.

I’ve been mucking around in the script files for Chicken, and I’ve noticed something strange. The line in the script that tests if it can find the utilities has “os.system(u)”, where u is a string. I have substituted the literal ‘egg2bam’ and also ‘pview’, and in all cases the return value is 32512 (I did a little research, and it seems that is the overflow value. I guess it’s just being read as an unsigned int instead of a signed int, so it is your expected value of -1). However, if I make a simple Python script that just calls os.system(‘egg2bam’) it returns 256. I really don’t know what to make of that.

However, I modified the code so that no matter what it would pass through with no errors by commenting out a line (“error = True”), and the exporter works fine, even bringing up pview after the export. egg2bam seems not to work though.

I guess my problem is mostly fixed, but any further help would be greatly appreciated.

EDIT:

My default shell is BASH; I don’t know if that applies to Mac, or just Linux. I’m really just confused why what seems like an equivalent command returns different values in different places.

Ok, my best guess right now is permissions, specifically the python script when run in Blender does not have permission to execute the Panda stuff. I got this because someone suggested permissions in relation to that error code when I googled it, and when I tested I got the error code 32256, which is 256 less than the code your getting, noting that macs return 256 rather than 0 for some silly reason, so it sort of makes sense. (Could be summed, but more likely and’ed - the bit sequences if treated as flags are interesting - 32256 is bits 9 through 14, whilst 32512 is bits 8 through 14, noting that 256 is bit 8 on its own.)

To test I just made a pair of python files:
other.py:

#! /usr/bin/env python
print 'Hello'

and

test.py:

#! /usr/bin/env python
import os
ret_code = os.system('./other.py')
print ret_code

and then ran them with the execute bit set and unset on other.py. If you could do the same test I would be very interested in the result…

Of course, this would mean that when you run those python scripts inside Blender they, for some reason, don’t have permission to run the Panda executables - not sure what the cause of that is, but I know macs have quite a tight security model, so I can certainly see it happening. Some kind of sand boxing perhaps? Other possibility is some strangeness in Blender, but that seems very unlikely. If you come up with a solution please tell me so I can put it in the installation guide!

(The shell matters btw because the system function runs the command inside the default shell - if you have a strange default shell os.system can, unsurprisingly, do very strange things. bash is as normal as it gets however.)

You were absolutely right:

chmod -x other.py
python test.py
sh: ./other.py: Permission denied
32256
chmod +x other.py
python test.py
Hello
0

So I tried setting the execute bit for the egg2bam file. Blender still tells me permission is denied. Here are the entries in the console, with the execute bit unset:

12/3/09 3:28:07 PM [0x0-0x1e8117f3].org.blenderfoundation.blender[19379] sh: egg2bam: command not found

…and with it set:

12/3/09 3:29:14 PM [0x0-0x1e8117f3].org.blenderfoundation.blender[19379] Compiled with Python version 2.5.1. 
12/3/09 3:29:14 PM [0x0-0x1e8117f3].org.blenderfoundation.blender[19379] Checking for installed Python... got it! 
12/3/09 3:29:14 PM [0x0-0x1e8117f3].org.blenderfoundation.blender[19379] returned status:  32512 
12/3/09 3:29:14 PM [0x0-0x1e8117f3].org.blenderfoundation.blender[19379] Settings for export not found. Using defaults. 
12/3/09 3:29:14 PM [0x0-0x1e8117f3].org.blenderfoundation.blender[19379] performed call egg2bam with return code 127 

I am even more confused now, because it seems to make a difference whether the exe. bit is set or unset, but still won’t allow the script to run properly.

I modified your test.py to see what it would find:

#! /usr/bin/env python 
import os 
ret_code = os.system('egg2bam') 
print ret_code 

With the result (unset):

python test2.py
sh: /Applications/Panda3D/1.6.2/bin/egg2bam: Permission denied
32256

…and (set):

python test2.py

You must specify the egg file(s) to read on the command line.

Usage:
  egg2bam [opts] input.egg output.bam
  egg2bam [opts] -o output.bam input.egg

256

See what you can make of that. I’ll be back in a bit. Thanks so much.

One more thought I had:

I did some research, and found that Python’s os.system() is implemented using the C function system() from stdlib.h. That is, in turn, implemented (to the best of my understanding) by feeding the string to POSIX. Could it be that this problem arises out of a difference between the Bash shell I run in Terminal, and the POSIX shell? I really don’t understand the shells, and I wasn’t able to find good info on them.

Thanks again.

Hmmm, I’m not sure - you got 32256 when Blender is kicking out 32512, so I can’t be convinced that this diagnosis is precisely right, though I suspect its close. What about user permissions - is Blender running as a different user to the file and the file doesn’t have read permissions? I have to admit I am running out of ideas - it seems very strange for a mac to behave this differently, and Google is failing to turn up anything useful.

With regards to the terminal posix is not a shell, its a standard for OS interfaces shared by all unix-like OS’s - posix then passes the call through to the underlying shell. We are certainly looking at a mac specific difference, which could be in this system, but could just as easily be elsewhere.

The high-order 8 bits of the value returned by system() are a little bit random. There are a few bits in there that have specific meaning, and they indicate the particular signal that stopped the app or whatever. Python might provide functions to decode these in the subprocess or os module, I’m not sure. (In C these are decoded by the WTERMSIG, WCOREDUMP, WIFSTOPPED, etc. macros.) The low-order 8 bits is the value returned by exit() from within the program itself. See “man waitpid” for more about this.

In any case, certainly the execute permissions of the binary are critical. You can’t successfully execute any program that doesn’t have the execute permission set. You should also ensure that the execute permissions are set on your .so’s and .dylib’s; sometimes this is important too, though this varies on different operating systems.

David

I can obviously manage without egg2bam, so for now I’m giving up on figuring this one out.

Thanks to both of you.

Happy gaming.

I finally configured chicken to export models with blender.

I use MAC (snow leopard). You have to set a environment variable like this:

export PATH=/Developer/Tools/Panda3D:$PATH

(because at this address there is the tool “egg2bam”)

After that you probably need to restart your computer, and then associate this path to chicken for blender.