On Jun 21, 2:01 pm, Yarin <[email protected]> wrote:
> Got it!
> Stripped the try-catch and let the import fail...
>
> TICKET:
> ExtractionError: Can't extract file(s) to egg cache
>
> The following error occurred while trying to extract file(s) to the
> Python egg
> cache:
>
>   [Errno 13] Permission denied: '/.python-eggs'

Note:  This is root directory (!) ---  probably the "home" directory
for the user in question
>
> The Python egg cache directory is currently set to:
>
>   /.python-eggs
>
> Perhaps your account does not have write access to this directory?
> You can
> change the cache directory by setting the PYTHON_EGG_CACHE environment
> variable to point to an accessible directory.

Yes - what you want to do; google on PYTHON_EGG_CACHE and wsgi, for
example.
This is a place where python can (if needed) _temporarily_ extract
eggs.

>
> END TICKET
>
> Solution:
>
> $ mkdir /var/www/web2py/python-eggs
> $ sudo chown -R apache:apache python-eggs

It doesn't matter so much you owns this, as long as it's writable and
readable by your process.
It could just as logically be in /tmp directory (that way it would
clean up at system reboot too...)

>
> Then in web2py/gluon/tools.py:
>
>    3285         try:
>
> (Inserted)
> import os
> os.environ['PYTHON_EGG_CACHE'] = '/var/www/web2py/python-eggs'
>
>    3286             import pyamf
>    3287             import pyamf.remoting.gateway
>    3288         except:
>    3289             return "pyamf not installed or not in Python
>
> and it works!
>
> So my final questions to you is can you think of a more elegant,
> permanent way of setting this up?  Is it bad practice to repeatedly
> set environment vars in multi-threaded code?

You probably want to do this at web2py start, for web2py.   You should
be able to add this to options_std.py;  I think you should be able,
alternatively, to do this
in your parameters*.py file
(see http://www.web2py.com/book/default/section/4/1?search=environ).

that is, put these lines in either:

import os
os.environ[PYTHON_EGG_CACHE]=....

- Yarko


>  And it's probably not
> wise to assign ownership of the eggs cache to the apache user, as I
> assume it may be used for other things.  Thoughts?
>
> On Jun 21, 2:29 pm, Yarko Tymciurak <[email protected]>
> wrote:
>
>
>
> > On Jun 21, 12:18 pm, Yarin <[email protected]> wrote:
>
> > > @Yarko
>
> > > > Try to compare these two:
> > > > $ python -c 'import sys; print sys.path'
> > > > and, from your web2py directory:
> > > > $ python web2py.py -S welcome
> > > > >>> import sys;  print sys.path
> > > > Compare the two to see what's missing;
>
> > > Results, in order:
>
> > > [
> > > '',
> > > '/usr/lib/python2.5/site-packages/PyAMF-0.5.1-py2.5-linux-i686.egg',
> > > '/usr/lib/python25.zip',
> > > '/usr/lib/python2.5',
> > > '/usr/lib/python2.5/plat-linux2',
> > > '/usr/lib/python2.5/lib-tk',
> > > '/usr/lib/python2.5/lib-dynload',
> > > '/usr/lib/python2.5/site-packages',
> > > '/usr/lib/python2.5/site-packages/gtk-2.0'
> > > ]
>
> > > [
> > > '/var/www/web2py',
> > > '/usr/lib/python2.5/site-packages/PyAMF-0.5.1-py2.5-linux-i686.egg',
> > > '/usr/lib/python25.zip',
> > > '/usr/lib/python2.5',
> > > '/usr/lib/python2.5/plat-linux2',
> > > '/usr/lib/python2.5/lib-tk',
> > > '/usr/lib/python2.5/lib-dynload',
> > > '/usr/lib/python2.5/site-packages',
> > > '/usr/lib/python2.5/site-packages/gtk-2.0',
> > > '../gluon',
> > > '/var/www/web2py/site-packages'
> > > ]
>
> > > I don't see a problem here- do you?
>
> > No - I do not see this showing the problem - your pyamf installation
> > appears to be ok.
>
> > You can do what Massimo suggested to get more detailed info.
>
> > Also - fedora has a secure kernel which ...  I might suspect some
> > things because of that.
> > You might start by looking at the owner/group of your pyamf egg, and
> > comparing what / who web2py is running (the simple test would be to
> > run web2py as yourself - you've seen the path is the same;  see if
> > your imports work from the web2py shell when you are running as
> > "you" (instead of through apache, as some other process user/group).
>
> > If the web2py command line import works, then you may have an issue
> > with the user/group that web2py is running as under apache - or
> > perhaps even fedora protecting what anything running from apache can
> > access.
>
> > After you have tried the import runing from your shell as you (if it
> > works) you could try as sudo -u www-data (or whatever the web2py
> > process is running under);  this will help you sort out if it is a
> > user related constraint, or an apache process constraint that fedora
> > is putting on you.
>
> > You may also try what Massimo suggested;
>
> > Let us know your progress.
>
> > - Yarko
> > Also, run
>
> > > I've even run
>
> > > $ chmod -R 777 /usr/lib/python2.5/site-packages/PyAMF-0.5.1-py2.5-
> > > linux-i686.egg
>
> > > to ensure it's not a permissions issue, but I'm getting the same
> > > result...
>
> > > On Jun 21, 12:45 pm, Yarko Tymciurak <[email protected]>
> > > wrote:
>
> > > > On Jun 21, 10:57 am, Yarin <[email protected]> wrote:
>
> > > > > @mdipierro - Do you mean do I have multiple versions of Python on my
> > > > > system?
>
> > > > > $ ls usr/bin/ shows ->
> > > > > ...
> > > > > -rwxr-xr-x 1 root root         82 Jul 10  2008 pydoc
> > > > > -rwxr-xr-x 1 root root       3572 Jul 10  2008 python
> > > > > lrwxrwxrwx 1 root root         16 Nov 27  2009 python-config ->
> > > > > python2.5-config
> > > > > lrwxrwxrwx 1 root root          6 Nov 27  2009 python2 -> python
> > > > > -rwxr-xr-x 1 root root       3572 Jul 10  2008 python2.5
> > > > > -rwxr-xr-x 1 root root       1418 Jul 10  2008 python2.5-config
>
> > > > > but all of these refer to version Python2.5.1
>
> > > > > Moreover, I know that that error is thrown from web2py/gluon.tools.py
> > > > >    3285         try:
> > > > >    3286             import pyamf
> > > > >    3287             import pyamf.remoting.gateway
> > > > >    3288         except:
> > > > >    3289             return "pyamf not installed or not in Python
> > > > > sys.path"
>
> > > > > but when I run from the command line...
>
> > > > > $ python
>
> > > > > >>>> import pyamf
> > > > > >>>> import pyamf.remoting.gateway
>
> > > > Try to compare these two:
>
> > > > $ python -c 'import sys; print sys.path'
>
> > > > and, from your web2py directory:
>
> > > > $ python web2py.py -S welcome
>
> > > > >>> import sys;  print sys.path
>
> > > > Compare the two to see what's missing;
>
> > > > You can also find where your pyamf was installed -
>
> > > > If you are not seeing it somewhere like /usr/lib/python2.5/site-
> > > > packages (use your sys.path as a guide to the correct path), then it
> > > > is possible you made a local installation of pyamf --- if it appears
> > > > in somewhere in your $HOME directory, then that is likely your problem
> > > > - you installed it for yourself as a user, instead of site-wide.
> > > > Since apache does not run as you, your HOME install of pyamf is not in
> > > > the sys.path for web2py.
>
> > > > Hope this is helpful.  Let us know what you find.
>
> > > > > ...I get no errors
>
> > > > > I'm stumped- Is this a permissions issue?  What else can I test?
>
> > > > > My code:
>
> > > > > rpc.py:
>
> > > > > # coding: utf8
> > > > > # try something like
> > > > > def index(): return dict(message="hello from rpc.py")
>
> > > > > from gluon.tools import Service
> > > > > service = Service(globals())
>
> > > > > def call():
> > > > >     session.forget()
> > > > >     return service()
>
> > > > > @service.amfrpc3("mydomain")
> > > > > def test():
> > > > >     return "Test!!!"
>
> > > > > Flex client code: (Doubt it's helpful as this seems like a server, not
> > > > > client, issue)
>
> > > > > <mx:RemoteObject
> > > > >         id="amfService"
> > > > >         endpoint="http://{myPublicIP}/pyamf_test/rpc/call/amfrpc3";
> > > > >         destination="mydomain"
> > > > >         showBusyCursor="true">
> > > > >         <mx:method name="test"
> > > > >                 result="resultHandler(event)" 
> > > > > fault="faultHandler(event)"
> > > > >                 />
> > > > > </mx:RemoteObject>
>
> > > > > And a side question:  What is the purpose of the domain field?  Can it
> > > > > be anything?
>
> > > > have no idea...
>
> > > > > @Kuba - How am I supposed to reboot web2py when it's running off of
> > > > > mod_wsgi?  I haven't figured that out yet- thought that since it was
> > > > > tied in with Apache an Apache restart would reboot web2py too.
>
> > > > Apache restart will do it;  depending on the mod_wsgi, there are
> > > > simpler restarts of the wsgi thread associated with your web2py that
> > > > do not require a restart of _all_ the sites your apache is running.
> > > > You probably don't care about that at this point (but if you do, read
> > > > up on mod_wsgi --- you touch a script to get the wsgi thread only to
> > > > restart, thus restarting web2py).
>
> > > > > However, I went so far as to reboot the whole system, so don't think
> > > > > that's the problem.
>
> > > > It's not.
>
> > > > - Yarko
>
> > > > > Thanks--
>
> > > > > On Jun 21, 2:26 am, mdipierro <[email protected]> wrote:
>
> > > > > > On Jun 20, 8:50 pm, Yarin <[email protected]> wrote:
>
> > > > > > > I set up web2py on a Fedora EC2 server, running with mod_wsgi and
> > > > > > > Apache.  Everything was working great with the initial setup.  I 
> > > > > > > then
> > > > > > > tried to get amf working, by doing the following:
>
> > > > > > > $ easy_install pyamf
> > > > > > > $ apachectl restart
>
> > > > > > > However, when I try to connect with my Flex client, I get:
> > > > > > > "pyamf not installed or not in Python sys.path"
>
> > > > > > > When I run web2py from the command line and check sys.path, I see
> > > > > > > '/usr/lib/python2.5/site-packages/PyAMF-0.5.1-py2.5-linux-i686.egg'
>
> > > > > > > Is restarting Apache not enough?   Do RPC services even run 
> > > > > > > through
> > > > > > > Apache? (excuse my ignorance)
>
> > > > > > It should. Is it possible you have different versions of Python?
>
> > > > > > > Thanks- Yarin

Reply via email to