Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cross-compiled Python can't find basic modules (math, operator, etc)

I can't seem to import any of the basic modules located in the "lib-dynload" directory. They are all there, but I get the error: "ImportError: No module named X" when trying to import them.

I checked my sys.path and it includes the directory where all of these modules are located and my PYTHONHOME environment variable is set correctly. I'm at a bit of a loss as to what the problem could be. Some background info: This is cross-compiled from Python 2.6.6 source and installed onto an ARM embedded Linux board with Angstrom.

It did have python on there before, I had tried to bit-bake it into the image but it was missing a lot of stuff. I ended up doing my best to clean the directory tree of anything to do with the previous python before loading on my cross compiled version.

An strace of a simple script that just attempts to import math: http://pastebin.com/3XgJ3nPR

like image 935
Jon Avatar asked Nov 04 '22 22:11

Jon


1 Answers

I see no checks in that trace for filenames like math.so or mathmodule.so which might indicate that shared-object modules are turned off entirely — that the version of Python you have compiled cannot load binary modules dynamically.

More: looking over the config.out from my most recent Python build, I see several lines where Python is investigating whether the platform will let it dynamically load binary modules that end in .so:

checking for dlopen... yes
checking DYNLOADFILE... dynload_shlib.o
checking MACHDEP_OBJS... MACHDEP_OBJS

What do these lines say on your cross-compile?

like image 51
Brandon Rhodes Avatar answered Nov 11 '22 02:11

Brandon Rhodes