having trouble importing a module from local directory
Marcelo Ramos
mramos at montevideo.com.uy
Fri May 12 18:14:55 EDT 2006
vduber6er escribió:
> First off this is in unix.
>
> I have a C file that has python embedded in it. In the script I have
> the following
>
> PyRun_SimpleString(code);
>
> where
> code = "import mymodule"
>
> however I get this error
>
> Traceback (most recent call last):
> File "<string>", line 1, in ?
> ImportError: No module named mymodule
> Object not found
> Segmentation fault
>
> If i just run python from my local path then type "import mymodule" in
> the python prompt this is fine. I'm guessing when I am embedding my
> python script in the C code the local directory is no longer the
> directory where my C code resides. How can i tell python to load the
> module from my current local directory?
>
>
Try adding the directory where your mymodule module lives to the
PYTHONPATH environment variable before running your c program.
--
Marcelo Ramos
Fedora Core 5 | 2.6.16
Socio UYLUG Nro 125
More information about the Python-list
mailing list