Nanor
Nanor

Reputation: 2550

IOError on production server

I'm writing a web app in Django that uses the following third party libraries:

Django==1.6.1
argparse==1.2.1
cffi==0.8.1
pycparser==2.10
pylast==0.5.11
pyspotify==2.0.0a1
wsgiref==0.1.2

I've been installing pyspotify with sudo pip install git+git://github.com/mopidy/pyspotify.git as I want the dev version.

When I run the Django app locally, everything works as desired. When I pull the changes onto my Apache server, pip install -r requirements.txt, restart the server and access the IP I get the following error:

Environment:


Request Method: GET
Request URL: http://ec2-54-196-205-226.compute-1.amazonaws.com/

Django Version: 1.6.1
Python Version: 2.7.3
Installed Applications:
('django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'raudio')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware')


Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
  101.                 resolver_match = resolver.resolve(request.path_info)
File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" in resolve
  320.                     sub_match = pattern.resolve(new_path)
File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" in resolve
  222.             return ResolverMatch(self.callback, args, kwargs, self.name)
File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" in callback
  229.         self._callback = get_callable(self._callback_str)
File "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py" in wrapper
  32.         result = func(*args)
File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" in get_callable
  96.             mod = import_module(mod_name)
File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py" in import_module
  40.         __import__(name)
File "/home/ubuntu/public_html/clupus.com/clupus/raudio/views.py" in <module>
  9. import spotify
File "/usr/local/lib/python2.7/dist-packages/spotify/__init__.py" in <module>
  53.     ext_package='spotify')
File "/usr/local/lib/python2.7/dist-packages/cffi/api.py" in verify
  339.         lib = self.verifier.load_library()
File "/usr/local/lib/python2.7/dist-packages/cffi/verifier.py" in load_library
  73.                         self._write_source()
File "/usr/local/lib/python2.7/dist-packages/cffi/verifier.py" in _write_source
  125.             file = open(self.sourcefilename, 'w')

Exception Type: IOError at /
Exception Value: [Errno 2] No such file or directory: '/usr/local/lib/python2.7/dist-packages/spotify/__pycache__/_cffi__x3868ddbbx77caf6c5.c'

When I pip freeze on the server all dependencies appear met so I'm not sure what the problem is. Does anyone have an idea?

Upvotes: 3

Views: 1916

Answers (2)

Nanor
Nanor

Reputation: 2550

A comment in my question suggested I reinstall pyspotify. I tried to do so and got a gcc error. Line 5 tells us that the problem is with libspotify, a library which pyspotify depends on. I thought I had that installed but apparently not. I installed that, restarted the server and now everything works as intended.

Upvotes: 0

ptr
ptr

Reputation: 3384

Assuming you get the same complier error as I do when trying to install:

c/_cffi_backend.c:14:17: fatal error: ffi.h: No such file or directory

 #include <ffi.h>

                 ^

compilation terminated.

error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

I found the fix here by doing apt-get install libffi-dev

Upvotes: 5

Related Questions