no module named error

Benjamin Kaplan benjamin.kaplan at case.edu
Thu Dec 10 10:09:43 EST 2009


On Thu, Dec 10, 2009 at 9:56 AM, Joe <invalid.emal at at.address> wrote:
>> No, the import-mechanism of python doesn't take LD_LIBRARY_PATH into
>> account, and even if it did - _moda.la is a simple archive-file, not a
>> shared library. It can't be dynamically loaded. Something in your
>> build-process is not working.
>
> So how should my stuff find these libs?
>
> Here's what I've recently learned ...
>
> So if I have the dir path of my c libs inside my exported
> LD_LIBRARY_PATH (which includes the following files),  along w/ the dir
> to the *.la file ...
>
> _moda.a
> _moda.la -> ../_moda.la
> _moda.lai
> _moda.so -> _moda.so.2.0.1
> _moda.so.2 -> _moda.so.2.0.1
> _moda.so.2.0.1
> _moda.so.2.0.1T
> _moda_la-moda_wrap.o
>
> I get the 'ImportError: No module named _moda' error as in previous
> post. But as I think your saying above, this should not work because
> LD_LIBRARY_PATH doesn't get used.
>
> I was at the python command line '>>>' and I did the following command.
>
> import sys
> sys.path.append('/home/me/my/c/libs/path/.libs')
> # this is the path to the above listed files, and then when I did ...
>
>   import moda
>
> Everything worked just fine.
>
> But I'm not quite sure how to fix it in my script or env.
> --
> http://mail.python.org/mailman/listinfo/python-list
>

http://docs.python.org/library/sys.html
"""
sys.path

    A list of strings that specifies the search path for modules.
Initialized from the environment variable PYTHONPATH, plus an
installation-dependent default.

    As initialized upon program startup, the first item of this list,
path[0], is the directory containing the script that was used to
invoke the Python interpreter. If the script directory is not
available (e.g. if the interpreter is invoked interactively or if the
script is read from standard input), path[0] is the empty string,
which directs Python to search modules in the current directory first.
Notice that the script directory is inserted before the entries
inserted as a result of PYTHONPATH.

    A program is free to modify this list for its own purposes.

    Changed in version 2.3: Unicode strings are no longer ignored.

"""
Python uses the PYTHONPATH variable to find modules/libraries, not
LD_LIBRARY_PATH.



More information about the Python-list mailing list