Re: library import issue.

2008-06-16 Thread Peter Bengtsson



On Jun 16, 11:07 am, "James Matthews" <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I am trying to import a library that is in a non-standard location ~/opt/lib
> (I am in a shared environment) and i added it to my "LD_LIBRARY_PATH"
> however Django tells me it cannot find it and me a 500 error.
>
> In python i can import the library but not in Django. I compiled this
> library using Swig.
>
> Details:
>
> Error was: libhdate.so.1: cannot open shared object file: No such file or
> directory
>
> but in python...
> [machine]$ python -c "from hdate import Hdate"
> [machine]$
>

Clearly it's a different sys.path in the two pythons.
Assert yourself first that you're using the exact same python binary
for django and for python on the command line.
Try this:
$ python
>>> import hdate
>>> import sys
>>> from pprint import pprint
>>> pprint(sys.path)

Then try it from the django shell
$ python manage.py shell
>>> import hdate
... ImportError ...
>>> import sys
>>> from pprint import pprint
>>> pprint(sys.path)

Then compare and find out what's going on.



> Any help?
>
> James
>
> --http://search.goldwatches.com/?Search=Movado+Watcheshttp://www.jewelerslounge.comhttp://www.goldwatches.com

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: library import issue.

2008-06-16 Thread James Matthews
Thank You very much Peter. However this is the output of what you told me to
do. And i don't get an import error when i try to import Hdate under the
django shell

Python 2.5.2 (r252:60911, Mar 30 2008, 02:18:56)
[GCC 3.3.5 (Debian 1:3.3.5-13)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import hdate
>>> import sys
>>> from pprint import pprint
>>> pprint(sys.path)
['',
 '/home/user/opt/lib/python2.5/site-packages/setuptools-0.6c5-py2.5.egg',
 
'/home/user/opt/lib/python2.5/site-packages/MySQL_python-1.2.2-py2.5-linux-i686.egg',
 '/home/.debase/user',
 '/home/user/opt/lib/python2.5/site-packages',
 '/home/user/django/django_src',
 '/home/user/django/django_projects',
 '/home/user/opt/lib',
 '/home/user/opt/lib/python25.zip',
 '/home/user/opt/lib/python2.5',
 '/home/user/opt/lib/python2.5/plat-linux2',
 '/home/user/opt/lib/python2.5/lib-tk',
 '/home/user/opt/lib/python2.5/lib-dynload',
 '/home/user/opt/lib/python2.5/site-packages/PIL']
>>>


On Mon, Jun 16, 2008 at 12:39 PM, Peter Bengtsson <[EMAIL PROTECTED]> wrote:

>
>
>
> On Jun 16, 11:07 am, "James Matthews" <[EMAIL PROTECTED]> wrote:
> > Hi,
> >
> > I am trying to import a library that is in a non-standard location
> ~/opt/lib
> > (I am in a shared environment) and i added it to my "LD_LIBRARY_PATH"
> > however Django tells me it cannot find it and me a 500 error.
> >
> > In python i can import the library but not in Django. I compiled this
> > library using Swig.
> >
> > Details:
> >
> > Error was: libhdate.so.1: cannot open shared object file: No such file or
> > directory
> >
> > but in python...
> > [machine]$ python -c "from hdate import Hdate"
> > [machine]$
> >
>
> Clearly it's a different sys.path in the two pythons.
> Assert yourself first that you're using the exact same python binary
> for django and for python on the command line.
> Try this:
> $ python
> >>> import hdate
> >>> import sys
> >>> from pprint import pprint
> >>> pprint(sys.path)
>
> Then try it from the django shell
> $ python manage.py shell
> >>> import hdate
> ... ImportError ...
> >>> import sys
> >>> from pprint import pprint
> >>> pprint(sys.path)
>
> Then compare and find out what's going on.
>
>
>
> > Any help?
> >
> > James
> >
> > --
> http://search.goldwatches.com/?Search=Movado+Watcheshttp://www.jewelerslounge.comhttp://www.goldwatches.com
>
> >
>


-- 
http://search.goldwatches.com/?Search=Movado+Watches
http://www.jewelerslounge.com
http://www.goldwatches.com

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: library import issue.

2008-06-16 Thread Karen Tracey
On Mon, Jun 16, 2008 at 6:07 AM, James Matthews <[EMAIL PROTECTED]> wrote:

> Hi,
>
> I am trying to import a library that is in a non-standard location
> ~/opt/lib (I am in a shared environment) and i added it to my
> "LD_LIBRARY_PATH" however Django tells me it cannot find it and me a 500
> error.
>
> In python i can import the library but not in Django. I compiled this
> library using Swig.
>
> Details:
>
> Error was: libhdate.so.1: cannot open shared object file: No such file or
> directory
>
> but in python...
> [machine]$ python -c "from hdate import Hdate"
> [machine]$
>
>
> Any help?
>

You do not mention how you are running Django.  Using the development
server, under Apache, etc?  Changes you have made to get the import to work
for your own user login will not necessarily be in effect when running under
Apache, for instance.  So that could be part of the problem, but it's hard
to be sure without more specifics of the environment in which you are
running Django.

Karen

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: library import issue.

2008-06-16 Thread James Matthews
Sorry,

I am running Django in a shared hosting environment, Apache, Fcgi

James

On Mon, Jun 16, 2008 at 2:43 PM, Karen Tracey <[EMAIL PROTECTED]> wrote:

> On Mon, Jun 16, 2008 at 6:07 AM, James Matthews <[EMAIL PROTECTED]>
> wrote:
>
>> Hi,
>>
>> I am trying to import a library that is in a non-standard location
>> ~/opt/lib (I am in a shared environment) and i added it to my
>> "LD_LIBRARY_PATH" however Django tells me it cannot find it and me a 500
>> error.
>>
>> In python i can import the library but not in Django. I compiled this
>> library using Swig.
>>
>> Details:
>>
>> Error was: libhdate.so.1: cannot open shared object file: No such file or
>> directory
>>
>> but in python...
>> [machine]$ python -c "from hdate import Hdate"
>> [machine]$
>>
>>
>> Any help?
>>
>
> You do not mention how you are running Django.  Using the development
> server, under Apache, etc?  Changes you have made to get the import to work
> for your own user login will not necessarily be in effect when running under
> Apache, for instance.  So that could be part of the problem, but it's hard
> to be sure without more specifics of the environment in which you are
> running Django.
>
> Karen
>
> >
>


-- 
http://search.goldwatches.com/?Search=Movado+Watches
http://www.jewelerslounge.com
http://www.goldwatches.com

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: library import issue.

2008-06-16 Thread Karen Tracey
On Mon, Jun 16, 2008 at 8:48 AM, James Matthews <[EMAIL PROTECTED]> wrote:

> Sorry,
>
> I am running Django in a shared hosting environment, Apache, Fcgi
>

Then you need to make sure that whatever modifications you had to make in
your user shell environment to get the import to work are also in effect
when Django is running under Apache/FastCGI.  Unfortunately I don't have
experience with that setup so can't give any specific guidance but
presumably there are config files or something that would allow you to
influence the LD_LIBRARY_PATH and python path of the code you run in this
setup?

Karen

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: library import issue.

2008-06-16 Thread James Matthews
Karen

The library path is in both LD_LIBRARY_PATH and the PYTHONPATH

On Mon, Jun 16, 2008 at 3:09 PM, Karen Tracey <[EMAIL PROTECTED]> wrote:

> On Mon, Jun 16, 2008 at 8:48 AM, James Matthews <[EMAIL PROTECTED]>
> wrote:
>
>> Sorry,
>>
>> I am running Django in a shared hosting environment, Apache, Fcgi
>>
>
> Then you need to make sure that whatever modifications you had to make in
> your user shell environment to get the import to work are also in effect
> when Django is running under Apache/FastCGI.  Unfortunately I don't have
> experience with that setup so can't give any specific guidance but
> presumably there are config files or something that would allow you to
> influence the LD_LIBRARY_PATH and python path of the code you run in this
> setup?
>
> Karen
>
> >
>


-- 
http://search.goldwatches.com/?Search=Movado+Watches
http://www.jewelerslounge.com
http://www.goldwatches.com

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: library import issue.

2008-06-16 Thread Karen Tracey
On Mon, Jun 16, 2008 at 9:19 AM, James Matthews <[EMAIL PROTECTED]> wrote:

> Karen
>
> The library path is in both LD_LIBRARY_PATH and the PYTHONPATH


You mean you've specified it in the appropriate config file?  Based on the
results, though, it doesn't seem to be working.  What, exactly, did you
specify where?  I'm assuming you are using a setup similar to what is
described here:

http://www.djangoproject.com/documentation/fastcgi/#running-django-on-a-shared-hosting-provider-with-apache

?

If so then a couple of things occur to me.  It sounds like your code will be
running in the context of an Apache-spawned process, so a path like
"~/opt/lib" as you mention in your first mail won't, I don't think, resolve
to your home directory's opt/lib.  Did you fully-specify the path wherever
you put it?  The other possibility is that the Apache-spawned process does
not have permission to read this directory under your home directory.  Have
you changed permissions so that the Apache process can read this directory?

Karen

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: library import issue.

2008-06-17 Thread James Matthews
The server is running suExec therefore Apache executes as the user. So it
should be able to read my library.

James

On Mon, Jun 16, 2008 at 5:08 PM, Karen Tracey <[EMAIL PROTECTED]> wrote:

> On Mon, Jun 16, 2008 at 9:19 AM, James Matthews <[EMAIL PROTECTED]>
> wrote:
>
>> Karen
>>
>> The library path is in both LD_LIBRARY_PATH and the PYTHONPATH
>
>
> You mean you've specified it in the appropriate config file?  Based on the
> results, though, it doesn't seem to be working.  What, exactly, did you
> specify where?  I'm assuming you are using a setup similar to what is
> described here:
>
>
> http://www.djangoproject.com/documentation/fastcgi/#running-django-on-a-shared-hosting-provider-with-apache
>
> ?
>
> If so then a couple of things occur to me.  It sounds like your code will
> be running in the context of an Apache-spawned process, so a path like
> "~/opt/lib" as you mention in your first mail won't, I don't think, resolve
> to your home directory's opt/lib.  Did you fully-specify the path wherever
> you put it?  The other possibility is that the Apache-spawned process does
> not have permission to read this directory under your home directory.  Have
> you changed permissions so that the Apache process can read this directory?
>
> Karen
>
>
> >
>


-- 
http://search.goldwatches.com/?Search=Movado+Watches
http://www.jewelerslounge.com
http://www.goldwatches.com

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: library import issue.

2008-06-17 Thread Karen Tracey
On Tue, Jun 17, 2008 at 3:48 AM, James Matthews <[EMAIL PROTECTED]> wrote:

> The server is running suExec therefore Apache executes as the user. So it
> should be able to read my library.
>

SuEXEC cleans the environment before calling your code.  According to Step
19 described here:

http://httpd.apache.org/docs/2.0/suexec.html

the only environment variables that will be preserved in the environment
created for your code are those listed in the "safe environment list" that
is set during Apache configuration.  I'd guess that LD_LIBRARY_PATH is not
in that list.  You'd need to consult your hosting provider to be sure, but
you could check the value of os.environ.get('LD_LIBRARY_PATH') as a first
step to confirming this is the problem.  I'm guessing you'll find it is
None.

Karen

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---