Error while running '$ python manage.py collectstatic --noinput'.

73 views
Skip to first unread message

Ram

unread,
Dec 16, 2023, 9:02:46 PM12/16/23
to django...@googlegroups.com
Hi,

Did anyone hit this error before during production server or any type of deployment. We tried deployment using Digital Oceanś App platform as a pre-prod deployment to check whether this App platform is feasible for our Django web site, but we are hitting this error no matter what ever modification we change in settings.py to avoid this error. Tried a lot of Google search results to address this issue, but no luck so far. We are wondering whether anyone has any recommendations on this error. If you did not try Digital Oceanś app platform, what would be your recommendation for production server deployment? We are planning to use only app platforms to avoid infrastructure overhead.


[2023-12-17 01:40:06] │ -----> $ python manage.py collectstatic --noinput
[2023-12-17 01:40:06] │        Traceback (most recent call last):
[2023-12-17 01:40:06] │          File "/workspace/manage.py", line 23, in <module>
[2023-12-17 01:40:06] │            execute_from_command_line(sys.argv)
[2023-12-17 01:40:06] │          File "/app/.heroku/python/lib/python3.11/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line
[2023-12-17 01:40:06] │            utility.execute()
[2023-12-17 01:40:06] │          File "/app/.heroku/python/lib/python3.11/site-packages/django/core/management/__init__.py", line 420, in execute
[2023-12-17 01:40:06] │            django.setup()
[2023-12-17 01:40:06] │          File "/app/.heroku/python/lib/python3.11/site-packages/django/__init__.py", line 24, in setup
[2023-12-17 01:40:06] │            apps.populate(settings.INSTALLED_APPS)
[2023-12-17 01:40:06] │          File "/app/.heroku/python/lib/python3.11/site-packages/django/apps/registry.py", line 91, in populate
[2023-12-17 01:40:06] │            app_config = AppConfig.create(entry)
[2023-12-17 01:40:06] │                         ^^^^^^^^^^^^^^^^^^^^^^^
[2023-12-17 01:40:06] │          File "/app/.heroku/python/lib/python3.11/site-packages/django/apps/config.py", line 228, in create
[2023-12-17 01:40:06] │            import_module(entry)
[2023-12-17 01:40:06] │          File "/app/.heroku/python/lib/python3.11/importlib/__init__.py", line 126, in import_module
[2023-12-17 01:40:06] │            return _bootstrap._gcd_import(name[level:], package, level)
[2023-12-17 01:40:06] │                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[2023-12-17 01:40:06] │          File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
[2023-12-17 01:40:06] │          File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
[2023-12-17 01:40:06] │          File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
[2023-12-17 01:40:06] │          File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
[2023-12-17 01:40:06] │          File "<frozen importlib._bootstrap_external>", line 940, in exec_module
[2023-12-17 01:40:06] │          File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
[2023-12-17 01:40:06] │          File "/app/.heroku/python/lib/python3.11/site-packages/django_tables2/__init__.py", line 1, in <module>
[2023-12-17 01:40:06] │            from .columns import (
[2023-12-17 01:40:06] │          File "/app/.heroku/python/lib/python3.11/site-packages/django_tables2/columns/__init__.py", line 8, in <module>
[2023-12-17 01:40:06] │            from .jsoncolumn import JSONColumn
[2023-12-17 01:40:06] │          File "/app/.heroku/python/lib/python3.11/site-packages/django_tables2/columns/jsoncolumn.py", line 11, in <module>
[2023-12-17 01:40:06] │            from django.contrib.postgres.fields import HStoreField
[2023-12-17 01:40:06] │          File "/app/.heroku/python/lib/python3.11/site-packages/django/contrib/postgres/fields/__init__.py", line 1, in <module>
[2023-12-17 01:40:06] │            from .array import *  # NOQA
[2023-12-17 01:40:06] │            ^^^^^^^^^^^^^^^^^^^^
[2023-12-17 01:40:06] │          File "/app/.heroku/python/lib/python3.11/site-packages/django/contrib/postgres/fields/array.py", line 3, in <module>
[2023-12-17 01:40:06] │            from django.contrib.postgres import lookups
[2023-12-17 01:40:06] │          File "/app/.heroku/python/lib/python3.11/site-packages/django/contrib/postgres/lookups.py", line 4, in <module>
[2023-12-17 01:40:06] │            from .search import SearchVector, SearchVectorExact, SearchVectorField
[2023-12-17 01:40:06] │          File "/app/.heroku/python/lib/python3.11/site-packages/django/contrib/postgres/search.py", line 1, in <module>
[2023-12-17 01:40:06] │            import psycopg2
[2023-12-17 01:40:06] │          File "/app/.heroku/python/lib/python3.11/site-packages/psycopg2/__init__.py", line 51, in <module>
[2023-12-17 01:40:06] │            from psycopg2._psycopg import (                     # noqa
[2023-12-17 01:40:06] │        SystemError: initialization of _psycopg raised unreported exception
[2023-12-17 01:40:06] │
[2023-12-17 01:40:06] │  !     Error while running '$ python manage.py collectstatic --noinput'.
[2023-12-17 01:40:06] │        See traceback above for details.
[2023-12-17 01:40:06] │
[2023-12-17 01:40:06] │        You may need to update application code to resolve this error.
[2023-12-17 01:40:06] │        Or, you can disable collectstatic for this application:
[2023-12-17 01:40:06] │
[2023-12-17 01:40:06] │           $ heroku config:set DISABLE_COLLECTSTATIC=1
[2023-12-17 01:40:06] │
[2023-12-17 01:40:06] │        https://devcenter.heroku.com/articles/django-assets
[2023-12-17 01:40:06] │ ERROR: failed to build: exit status 1
[2023-12-17 01:40:07] │
[2023-12-17 01:40:07] │
[2023-12-17 01:40:07] │ For documentation on the buildpacks used to build your app, please see:
[2023-12-17 01:40:07] │
[2023-12-17 01:40:07] │    Python  v3.235.4  https://do.co/apps-buildpack-python
[2023-12-17 01:40:07] │
[2023-12-17 01:40:07] │  ✘ build failed

Best regards,
~Ram 

ram.mu...@gmail.com

unread,
Dec 16, 2023, 9:08:39 PM12/16/23
to Django users
Here is the static files setting that we have in our settings.py file:

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')

Ihor Dmytrenko

unread,
Dec 18, 2023, 5:02:47 PM12/18/23
to Django users
Why you have heroku in your log? Remove all old dependency configs in your settings first and then you need specify

```python
STATICFILES_DIRS = [
    os.path.join(BASE_DIR, 'static'),
]

STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATIC_URL = '/static/'

HOME_DIRECTORY_SELF_STORAGE = os.path.expanduser('~')
MEDIA_ROOT = os.path.join(HOME_DIRECTORY_SELF_STORAGE, 'public_html/')
MEDIA_URL = '/media/'
DEFAULT_FILE_STORAGE = 'django.core.files.storage.FileSystemStorage'
```

ram.mu...@gmail.com

unread,
Dec 19, 2023, 4:13:52 PM12/19/23
to Django users
Hi Ihor,

Thank you for your email. We do not have any reference to heroku but Digital Oceanś App platform is using heroku. We resolved  the above error by adding this environment variable:

DISABLE_COLLECTSTATIC = 1
But we are planning to enable this once the main deployment is done.

Best Regards,
~Ram
Reply all
Reply to author
Forward
0 new messages