Search code examples
pythondjangoherokupyo

Pyo Python DSP Module Won't Deploy to Heroku


So I'm trying to put up a demo of a django project on Heroku that runs fine locally and loads when I uninstall the package Pyo, but it throws an OSerror when I reinstall it (OSError at / Exception Value: /app/.pyo/3.6_64/libs/libasound-fb332ab3.so.2.0.0: cannot open shared object -- see below for full traceback). I've added a buildpack that installs the libasound and recommened packages, but I still get the error. What am I missing? I see the Linux wheel fix symlink (https://github.com/belangeo/pyo/blob/master/pyo/_linux_wheel_fix_symlinks.py). Is the issue here? Any help greatly appreciated.

Error:

Request Method: GET
Request URL: ---

Django Version: 3.0.3
Python Version: 3.6.10
Installed Applications:
['django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.sites',
 'core',
 'allauth',
 'allauth.account',
 'allauth.socialaccount',
 'allauth.socialaccount.providers.facebook',
 'allauth.socialaccount.providers.google']
Installed Middleware:
('whitenoise.middleware.WhiteNoiseMiddleware',
 'django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware')



Traceback (most recent call last):
  File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/base.py", line 100, in _get_response
    resolver_match = resolver.resolve(request.path_info)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/urls/resolvers.py", line 544, in resolve
    for pattern in self.url_patterns:
  File "/app/.heroku/python/lib/python3.6/site-packages/django/utils/functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/urls/resolvers.py", line 588, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/utils/functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/urls/resolvers.py", line 581, in urlconf_module
    return import_module(self.urlconf_name)
  File "/app/.heroku/python/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
    <source code not available>
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
    <source code not available>
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
    <source code not available>
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
    <source code not available>
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
    <source code not available>
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
    <source code not available>
  File "/app/autosubclub/urls.py", line 20, in <module>
    from core import views
  File "/app/core/views.py", line 8, in <module>
    from pyo import PVMix, PVMorph, PVAnal, SfPlayer, Vocoder, Server, Record, sndinfo
  File "/app/.heroku/python/lib/python3.6/site-packages/pyo/__init__.py", line 25, in <module>
    from . import _linux_wheel_fix_symlinks
  File "/app/.heroku/python/lib/python3.6/site-packages/pyo/_linux_wheel_fix_symlinks.py", line 88, in <module>
    libasound = ctypes.CDLL(libasound, mode=ctypes.RTLD_GLOBAL)
  File "/app/.heroku/python/lib/python3.6/ctypes/__init__.py", line 348, in __init__
    self._handle = _dlopen(self._name, mode)

Exception Type: OSError at /
Exception Value: /app/.pyo/3.6_64/libs/libasound-fb332ab3.so.2.0.0: cannot open shared object file: No such file or directory

Solution

  • I just want to leave this for anyone else who experiences this issue in the future. Pyo will not work on a hobby dev Heroku DYNO due to the symlink wheels created that attempt to reach out of the ./app folder for ibasound-fb332ab3.so.2.0.0 and libjack-07a61c7b.so.0.1.0, but Heroku apps can't reach out of that directory because it's where everything is stored.

    You can install on other cloud environments like Digital Ocean & Amazon EC2 where you can install Ubuntu on the server and have full access. I chose Digital Ocean for a while, but ended up just teaching the client how to run the web app locally and writing code to push the generated files to Amazon s3.