Home > Net >  Why am I seeing "No module named '_tkinter" when I deploy django to heroku?
Why am I seeing "No module named '_tkinter" when I deploy django to heroku?

Time:07-23

django works well on my local machine. But, when I deploy it to heroku, I see "ModuleNotFoundError" "No module named '_tkinter'". Though, I never imported "_tkinter" or "tkinter" in my code. Your help will be appreciated. Thank you.

ModuleNotFoundError at /

No module named '_tkinter'

Request Method: GET Request URL: https://howididit.herokuapp.com/ Django Version: 4.0.6 Exception Type: ModuleNotFoundError Exception Value:

No module named '_tkinter'

Exception Location: /app/.heroku/python/lib/python3.10/tkinter/init.py, line 37, in Python Executable: /app/.heroku/python/bin/python Python Version: 3.10.5 Python Path:

['/app/.heroku/python/bin', '/app', '/app/.heroku/python/lib/python310.zip', '/app/.heroku/python/lib/python3.10', '/app/.heroku/python/lib/python3.10/lib-dynload', '/app/.heroku/python/lib/python3.10/site-packages']

CodePudding user response:

If you don't use Tkinter, just remove it from /forms.py. otherwise it'll be imported.

If you want to use tkinter,then consider the below process

please try adding tkinter to your requirements.txt. If it fails, even after that, check if you have added Python buildpack. If both the cases pass, try shelling into your Heroku instances and run the following command:

sudo apt install python3-tk

This will install Tkinter library in your instance of Heroku. That will resolve your error.

CodePudding user response:

I found out these from pyexpat import model from turtle import title from attr import fields where imported in my forms.py. After deleting them, The problem was solved. Again, thank you all guys for your time, I really appreciate it.

  • Related