I'm trying to set up django with sage support on an Apache server. I'm 
working on Ubuntu. So far django and sage work fine, but I'm not able to 
make Apache work.
Here is what I've done:

   - Install django(1.7.1) in sage(6.2-x86_64)'s python(2.7.5) (
   http://ask.sagemath.org/question/7576/will-django-be-included-with-sage/)
   - Create a django project and app using sage's python
   - Run django's dev server (manage.py runserver)
      - If my views don't have '
      from sage.all import *
      
      ' no problems at all
      - If I include 'from sage.all import *', there is an 'signal only 
      works in main thread' error, which I can fix y running '
      python manage.py runserver --nothread --noreload
      
      ' (I don't know why it works)
   
So django and sage seem to get along. Now, when trying to put apache(2.4.7) 
into the picture, I have some problems. Now, the deal here is to make 
apache run sage's python interpreter for the wgsi.py file. For this, I 
downloaded mod_wsgi (4.3) and compile it for sage's python

   - remove libapache2-mod-wsgi and libapache2-mod-python
   - install apache dev tools 'apache2-prefork-dev'
   - ./configure --with-python=/path/to/sage/local/bin/python 
   
   (
   
https://code.google.com/p/modwsgi/wiki/QuickInstallationGuide#Configuring_The_Source_Code
   )

When attempting to do 'make', i get 
src/server/wsgi_python.h:24:20: fatal error: Python.h: No such file or 
directory
 #include <Python.h>
                    ^
compilation terminated.
apxs:Error: Command failed with rc=65536

which seems to be an error of not having sage's python dev tools (although 
the file Python.h is inside sage's root)


In order to work this around, I update sage's python by
sage -f python

   - make 
   - make install
   - load module in apache (wsgi.load<<LoadModule wsgi_module modules/
   mod_wsgi.so)
   - enable wsgi (a2enmod wsgi)
   - restart apache (stop and start)

After all this, apache return an error saying that is it running python 
with a different version

[wsgi:warn] [pid 22713:tid 139808010663808] mod_wsgi: Compiled for Python/
2.7.5. 
[wsgi:warn] [pid 22713:tid 139808010663808] mod_wsgi: Runtime using Python/
2.7.6. 


and says that can't find django

[wsgi:error] [pid 22716:tid 139807829260032] [client 127.0.0.1:55962] 
Traceback (most recent call last): [wsgi:error] [pid 22716:tid 
139807829260032] [client 127.0.0.1:55962] File "/path/to/project/wsgi.py", 
line 22, in <module> 
[wsgi:error] [pid 22716:tid 139807829260032] [client 127.0.0.1:55962] from 
django.core.wsgi import get_wsgi_application 
[wsgi:error] [pid 22716:tid 139807829260032] [client 127.0.0.1:55962] 
ImportError: No module named django.core.wsgi 



I checked sys.executable and points to sage's python, but sys.version_info 
gives me the wrong version (2.7.6) which is my main python, not sage's.

Update 1:
I fixed this by adding in apaches config
WSGIPythonHome /path/to/sage/local/ 

Then, I got an error in django saying:
'NoneType' object has no attribute 'replace'

and apache:

[wsgi:error] [pid 23369:tid 139816198420224] /path/tos/age/local/lib/python2
.7/site-packages/IPython/utils/path.py:304: UserWarning: IPython parent 
'/var/www' is not a writable location, using a temp directory. 
[wsgi:error] [pid 23369:tid 139816198420224] " using a temp directory."%
parent) 



which got fixed by changing ownership of /var/www to www-data:www-data, and 
set SAGE_ROOT in my wsgi.py file.

Now apache doesn't give me any error but django complains:

libcsage.so: cannot open shared object file: No such file or directory

libcsage.so: cannot open shared object file: No such file or directory


I still have django showing me that python's version is 2.7.6 (not sage's 
python apparently). I think is something to do with all the environment 
variables that sage uses, but I've not been able to solve it.

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to