ImportError raised when trying to load ‘crispy_forms.templatetags.crispy_forms_field’: No module named ‘django.utils.lru_cache’
I get that error ^^ when i try to run the command below:
heroku run python manage.py migrate
I have checked that my crispy forms version = 1.8.1
Please help!
What versions of Python and Django are you using? This looks like some kind of Python 2 vs 3 issue.
I am using python 3.6.9.So that shouldn’t be a problem
Just in case i was using python 2, i uninstalled all python version from my computer and re-installed python3 and i am still getting the same error
I think you might be seeing this bug, which is about compatibility with Django 3.0 and crispy forms, although it was meant to be fixed in version 1.8.1.
opened 08:00AM - 10 Dec 19 UTC
closed 08:03AM - 10 Dec 19 UTC
Package version: 1.7.2
Django version: 3.0
Python version: 3.7
Template pack: (Optional)
Description:
Because 'django.utils.lru_cache' is removed in django 3.0 so it is braking crispy_forms.
ImportError raised...
For bug reports please provide a stack trace and list of all the package versions you’re running.
Yep this was merged here Compatibility for Django 3.0 (#895) · django-crispy-forms/django-crispy-forms@23364c2 · GitHub .
I have checked that my crispy forms version = 1.8.1
I’d rebuild the virtualenv to be sure.
pip3 freeze gives me the following packages:
appdirs==1.4.3
apturl==0.5.2
asgiref==3.2.3
asn1crypto==0.24.0
Babel==2.4.0
beautifulsoup4==4.6.0
blinker==1.4
boto3==1.10.48
botocore==1.13.48
Brlapi==0.6.6
certifi==2019.11.28
chardet==3.0.4
chrome-gnome-shell==0.0.0
cliff==2.11.0
cmd2==0.7.9
command-not-found==0.3
cryptography==2.1.4
cupshelpers==1.0
debtcollector==1.13.0
decorator==4.1.2
defer==1.0.6
deprecation==1.0.1
distro-info===0.18ubuntu0.18.04.1
dj-database-url==0.5.0
Django==3.0
django-crispy-forms==1.8.1
django-heroku==0.3.1
django-storages==1.8
docutils==0.15.2
dogpile.cache==0.6.2
funcsigs==1.0.2
gunicorn==20.0.4
html5lib==0.999999999
httplib2==0.9.2
idna==2.6
iso8601==0.1.11
jmespath==0.9.4
jsonpatch==1.16
jsonpointer==1.10
keyring==10.6.0
keyrings.alt==3.0
keystoneauth1==3.4.0
language-selector==0.1
launchpadlib==1.10.6
lazr.restfulclient==0.13.5
lazr.uri==1.0.3
louis==3.5.0
lxml==4.2.1
macaroonbakery==1.1.3
monotonic==1.0
msgpack==0.5.6
munch==2.2.0
netaddr==0.7.19
netifaces==0.10.4
oauth==1.0.1
oauthlib==2.0.6
olefile==0.45.1
openstacksdk==0.11.3
os-client-config==1.29.0
os-service-types==1.1.0
osc-lib==1.9.0
oslo.config==5.2.0
oslo.i18n==3.19.0
oslo.serialization==2.24.0
oslo.utils==3.35.0
pbr==3.1.1
pexpect==4.2.1
Pillow==5.1.0
pipenv==2018.11.26
positional==1.1.1
prettytable==0.7.2
protobuf==3.0.0
psycopg2==2.7.5
pycairo==1.16.2
pycrypto==2.6.1
pycups==1.9.73
Pygments==2.2.0
pygobject==3.26.1
PyJWT==1.5.3
pymacaroons==0.13.0
PyNaCl==1.1.2
pyparsing==2.2.0
pyperclip==1.6.0
pyRFC3339==1.0
python-apt==1.6.4
python-dateutil==2.8.1
python-debian==0.1.32
python-decouple==3.3
python-dotenv==0.10.3
python-heatclient==1.14.0
python-keystoneclient==3.15.0
python-swiftclient==3.5.0
pytz==2019.3
pyxdg==0.25
PyYAML==3.12
reportlab==3.4.0
requests==2.18.4
requests-unixsocket==0.1.5
requestsexceptions==1.3.0
rfc3986==0.3.1
roman==2.0.0
s3transfer==0.2.1
SecretStorage==2.3.1
simplejson==3.13.2
six==1.13.0
sqlparse==0.3.0
stevedore==1.28.0
system-service==0.3
systemd-python==234
ubuntu-drivers-common==0.0.0
ufw==0.36
unattended-upgrades==0.1
urllib3==1.25.7
virtualenv==16.7.9
virtualenv-clone==0.5.3
wadllib==1.3.2
webencodings==0.5
whitenoise==5.0.1
wrapt==1.9.0
xkit==0.0.0
zope.interface==4.3.2
If I’m reading the Heroku docs correctly, heroku run runs the command remotely on Heroku’s servers. So then the question is, what is in your requirements.txt
file? Because that is what Heroku will (I think) install from - it doesn’t know what you have locally installed.
This is what my requirements.txt file has:
boto3==1.9.96
botocore==1.12.96
certifi==2018.10.15
chardet==3.0.4
dj-database-url==0.5.0
Django>=2.1.15
django-crispy-forms==1.7.2
django-heroku==0.3.1
django-storages==1.7.1
docutils==0.14
gunicorn==19.9.0
idna==2.7
jmespath==0.9.3
Pillow>=6.2.0
psycopg2==2.7.7
python-dateutil==2.8.0
pytz==2018.5
requests>=2.20.0
s3transfer==0.2.0
six==1.12.0
urllib3>=1.24.2
whitenoise==4.1.2
Well, there’s your problem
django-crispy-forms==1.7.2
Your requirements.txt
file should contain the versions of the packages that you’re using. Otherwise you will run into these kinds of issues a lot! One way you can do this, when you add a new package, is adding the package to requirements.txt
first and running pip install -r requirements.txt
, which installs everything in the file. That way your local and server versions won’t get out of sync so easily.
Ohhh got it.
Thanks a lot of the help, really appreciate it.