importing modules from alternate path

  • Thread starter Alexandru MoÈ™oi
  • Start date
A

Alexandru Moșoi

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
 
R

R. David Murray

=?UTF-8?Q?Alexandru__Mo=C8=99oi?= said:
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?

Possibly because the package gets installed into ~/lib/python, but
you haven't put that directory onto the PYTHONPATH.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,152
Members
46,697
Latest member
AugustNabo

Latest Threads

Top