Getting this error on run server locally - compressor.exceptions.UncompressableFileError: 'css/style.css' could not be found in the COMPRESS_ROOT '/Users/khushmeeet/dev/codex/staticfiles' or with staticfiles.

My Django project was running locally before. But today I am not able to server my app locally. I am getting this error “compressor.exceptions.UncompressableFileError: ‘css/style.css’ could not be found in the COMPRESS_ROOT ‘/Users/khushmeeet/dev/codex/staticfiles’ or with staticfiles.”

I have tried running collectstatic. But getting the following error

❯ python manage.py collectstatic                     

0 static files copied to '/Users/khushmeeet/dev/codex/staticfiles'.

I then ran find static command, to see where Django is looking for static files. But that failed too.

❯ python manage.py findstatic --verbosity 3 css/style.css
No matching file found for 'css/style.css'.

Looking in the following locations:
  /Users/khushmeeet/dev/codex/staticfiles

One more thing, I am using SCSS for my CSS files. Could this be an issue?

I am stuck here for far too long, and it’s frustrating, because I have tried everything, that I cloud, but still not able to locate the problem. Really appreciate, if someone could tell me, what is going on here?

Here are my project details -

├── codex
│   ├── __init__.py
│   ├── asgi.py
│   ├── settings.py
│   ├── urls.py
│   └── wsgi.py
├── db.sqlite3
├── main
│   ├── __init__.py
│   ├── admin.py
│   ├── apps.py
│   ├── forms.py
│   ├── migrations
│   ├── models.py
│   ├── static
│   ├── templates
│   ├── tests.py
│   ├── urls.py
│   └── views.py
├── manage.py
└── templates
    ├── base.html
    └── footer.html

My settings.py file

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'compressor',
    'widget_tweaks',
    'main'
]
STATICFILES_FINDERS = [
    'compressor.finders.CompressorFinder'
]

STATICFILES_DIRS = [
    'main/static',
]

COMPRESS_PRECOMPILERS = (
    ('text/x-scss', 'django_libsass.SassCompiler'),
)
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')

Hi Khushmeeet,

Since your question doesn’t indicate that you checked, I would start by verifying that the file exists at /Users/khushmeeet/dev/codex/staticfiles/css/style.css

Hi Tim,

I checked in the /Users/khushmeeet/dev/codex/staticfiles/css/style.css there are no files present. From what I understand, when I run python manage.py collectstatic, Django will copy my css files to /Users/khushmeeet/dev/codex/staticfiles aka STATIC_ROOT.

But when I run the command, I get this.

❯ python manage.py collectstatic                     

0 static files copied to '/Users/khushmeeet/dev/codex/staticfiles'.

I don’t see where your css files are in your project. Where is that file located in your project?

Hi Ken,

My CSS files are located under codex/main/static/css

Here is the complete tree.

.
├── CACHE
│   └── css
│       ├── style.23337793ede0.css
│       ├── style.526b15d32a8f.css
│       ├── style.56959eb751fe.css
│       ├── style.ce88d897647e.css
│       └── style.d6ff3016c650.css
├── css
│   ├── satoshi.css
│   └── style.scss
├── fonts
│   ├── Satoshi-Black.eot
│   ├── Satoshi-Black.ttf
│   ├── Satoshi-Black.woff
└── js
    └── main.js

I would specify the full path for your STATICFILES_DIRS setting:

STATICFILES_DIRS = [
    os.path.join(BASE_DIR, 'main/static'),
]

Tried you suggestion. Still same error

0 static files copied to '/Users/khushmeeet/dev/codex/staticfiles'.

Alright we’re narrowing it down. Your application indeed can’t find the static files to copy.

Is there a reason you removed the default static files finders? The installation documentation for django-compressor seems to indicate to leave them there.

I believe changing the following setting will resolve your issue:

STATICFILES_FINDERS = [
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
    'compressor.finders.CompressorFinder',
]
1 Like

Ah! working now. Thanks so much Tim for the help. This has been really frustrating.

I think I must have missed it while trying to integrate Django SCSS compressor.

Again, thanks a ton for the help Tim and Ken!

We’re glad to help. Best of luck with your projects moving forward!

1 Like