Deploy Shareabouts-API: Import Error djangorestframework

135 views
Skip to first unread message

Jason Merman

unread,
May 21, 2013, 12:14:28 AM5/21/13
to shareab...@googlegroups.com
Attempting to deploy the shareabouts-api to a local server, red hat 9, running Apache 2.2 with the mod_wsgi module.  (I also deployed to a Windows 8 R2 server resulting with the same error)

Following similar procedures as the Shareabouts web app deployment for WebFraction, I cloned the API's git project, created a virtualenv and installed the requirements using pip, configured httpd and then edited the wsgi.py and urls.py files.  

Apache starts without errors, when I open a browser and go to the servers root URL the Apache error log reports:

[info] mod_wsgi (pid=3443, process='shareabouts-api', application='www.sfbikeshare.com|'): Loading WSGI script '/var/www/html/shareabouts-api/src/project/wsgi.py'.
[error] mod_wsgi (pid=3443): Exception occurred processing WSGI script '/var/www/html/shareabouts-api/src/project/wsgi.py'.
[error] Traceback (most recent call last):
[error] File "/var/www/html/shareabouts-api/apienv/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 255, in __call__
[error]      response = self.get_response(request)
[error] File "/var/www/html/shareabouts-api/apienv/lib/python2.7/site-packages/django/core/handlers/base.py", line 178, in get_response
... (removed stack trace)
[error]     app = import_module(appname)
[error] File "/var/www/html/shareabouts-api/apienv/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
[error]      __import__(name)
[error] ImportError: No module named djangorestframework

I am a bit new to python, django and wsgi, however I noticed in the virtualenv's site-package directory there is no djangorestframework folder.  After some research, I found that djangorestframework, versions greater than 2.0, is deployed to a rest-framework folder.  Why is the django trying to load djangorestframework and not rest-framework?

In an attempt to remedy the problem, I renamed rest-framework to djangorestframework, although the initial error is removed, I get other errors because methods/variables are missing from djangorestframework classes.

I am not sure what to try next to resolved this problem. Any ideas would be appreciated.

Please let me know if I should include more httpd error log or more information.

Thank you,

Jason

Tom Coleman

unread,
May 21, 2013, 12:22:39 AM5/21/13
to shareab...@googlegroups.com
We had the problem on the weekend, deploying to EC2.

We had to switch to version 0.4.0 of djangorestframework to get the package structure that shareabouts api expected. Although the 0.4.0 release in the PyPI doesn't quite work (due to serialization issues), the only way we go it working was to copy code from a known good install that was named 0.4.0-dev. We are still chasing down exactly which commit of DRF this is so we can figure out a deterministic requirements.txt for future use.

It'd be nice if the shareabouts folks could help us out with this actually.

Cheers,
Tom
--
-- --
Shareabouts Developers group.
Unsubscribe: https://groups.google.com/d/forum/shareabouts-dev?hl=en
---
You received this message because you are subscribed to the Google Groups "Shareabouts Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shareabouts-d...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Mjumbe Poe

unread,
May 21, 2013, 9:23:16 AM5/21/13
to shareab...@googlegroups.com

Hey folks,

In the Shareabouts repository, there is a folder named libs/ that contains a version of DRF 0.4.0 that has what Shareabouts needs. The 0.x code path of DRF is no longer maintained, so we maintain our version there. You'll need to make sure that libs/django-rest-framework-0.4/ is on your Python path when you run the sever.

Since that version of DRF is no longer maintained, we are in the process of upgrading to the newest version. There were some (resoundingly good) decisions to break backwards compatibility in DRF in some big ways, so it's a fairly involved migration. You can check out the progress in the Shareabouts apiv2 branch.

Mjumbe

Reply all
Reply to author
Forward
0 new messages