问题
I'm trying to use Django's storages backend (for BotoS3)
settings.py:
INSTALLED_APPS = (
...
'storages',
...
)
as shown in http://django-storages.readthedocs.org/en/latest/index.html.
and, requirements.txt:
django-storages==1.1.8
But am getting the error:
django.core.exceptions.ImproperlyConfigured: ImportError storages: No module named storages
What am I doing wrong?
回答1:
There is a possibility that you are in a virtualenv and installing the package outside the virtualenv into the default python installation. Make sure you are not doing that.
回答2:
I had the same problem. In my case I solved the problem with
pip install django-storages
Collecting django-storages
Downloading django_storages-1.6.5-py2.py3-none-any.whl (47kB)
100% |################################| 51kB 358kB/s
Installing collected packages: django-storages
Successfully installed django-storages-1.6.5
It was executed inside my virtual environment.
回答3:
I had installed it within virtual env and was running the exact same issue. My problem was that I forgot to update my requirements.txt. So make you update that file!
回答4:
If you are using Pipenv make sure you install django-storages using
pipenv install django-storages
so that the Pipfile and Pipfile.lock are both updated.
I had installed using pip inside the virtualenv and requirements.txt was updated but still receiving this error. After digging around I noticed it was not added to the Pipfile. I ran the installer and it cleared up the error.
回答5:
If you are experiencing this error even though you've included 'storages'
in your INSTALLLED_APPS
and django-storages
in your requirements.txt
, check your STATICFILES_STORAGE
variable.
For previous versions of django-storages
, this should be set as:
STATICFILES_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
For newer versions of django-storages
, the package uses boto3
instead of boto
and this variable should be set as:
STATICFILES_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
If you're using either version and you've configured your DEFAULT_FILE_STORAGE
setting incorrectly, you'll receive an import error.
The correct settings can be found in the django-storages docs
来源:https://stackoverflow.com/questions/23207192/django-storages-import-error-no-module-named-storages