Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > importing modules from alternate path

Reply
Thread Tools

importing modules from alternate path

 
 
Alexandru Moșoi
Guest
Posts: n/a
 
      03-24-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
 
Reply With Quote
 
 
 
 
R. David Murray
Guest
Posts: n/a
 
      03-24-2009
=?UTF-8?Q?Alexandru__Mo=C8=99oi?= <(E-Mail Removed)> wrote:
> 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.

--
R. David Murray http://www.bitdance.com

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Importing v reloading modules modules Peter Peyman Puk Python 0 03-19-2010 05:09 PM
what's 'alternate' in <link rel=alternate>? Chris ASP .Net 2 03-04-2007 04:45 PM
Alternate initializers or alternate class? transfire@gmail.com Ruby 10 07-17-2006 03:20 AM
Importing modules from within other modules Tobiah Python 2 09-14-2003 09:18 PM



Advertisments