importing modules from alternate path

Discussion in 'Python' started by Alexandru Moșoi, Mar 24, 2009.

  1. 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
    Alexandru Moșoi, Mar 24, 2009
    #1
    1. Advertising

  2. =?UTF-8?Q?Alexandru__Mo=C8=99oi?= <> 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
    R. David Murray, Mar 24, 2009
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tobiah
    Replies:
    2
    Views:
    311
    Tobiah
    Sep 14, 2003
  2. Chris
    Replies:
    2
    Views:
    694
    Chris
    Mar 4, 2007
  3. Martin P. Hellwig
    Replies:
    0
    Views:
    278
    Martin P. Hellwig
    Apr 6, 2008
  4. Peter Peyman Puk

    Importing v reloading modules modules

    Peter Peyman Puk, Mar 19, 2010, in forum: Python
    Replies:
    0
    Views:
    297
    Peter Peyman Puk
    Mar 19, 2010
  5. Replies:
    10
    Views:
    337
    Sean O'Halpin
    Jul 17, 2006
Loading...

Share This Page