importing modules from alternate path

Alexandru Moșoi brtzsnr at gmail.com
Tue Mar 24 11:02:22 CET 2009


I'm trying with no succes to load modules from an alternate path. When
installing to default location (no --home specifed) everything works
as expected.

$ python setup.py install --home=~
running install
running build
running build_ext
running install_lib
running install_egg_info
Removing /home/voodoo/lib/python/PackageName-1.0-py2.6.egg-info
Writing /home/voodoo/lib/python/PackageName-1.0-py2.6.egg-info

$ printf "import demo" | PYTHONPATH=~ python
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named demo

$ printf "import demo" | PYTHONHOME=~ python
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named demo


Any idea why alternate path is not working?


--------- BEGIN OF setup.py
from distutils.core import setup, Extension

module1 = Extension('demo',
                    sources = ['demo.c'])

setup (name = 'PackageName',
       version = '1.0',
       description = 'This is a demo package',
       ext_modules = [module1])
--------- END OF end setup.py

--------- BEGIN OF demo.c
#include <Python.h>

static PyObject* demo_bla(PyObject *self) {
    return Py_BuildValue("i", 666);
}
--------- END OF demo.c



More information about the Python-list mailing list