0

When deoploying my website with Heroku, I run into the following issue:

ModuleNotFoundError: No module named 'qr_code'

so the website doesn't deploy

This is the log tail:

My requirements.txt contains the following:

asgiref==3.5.0
Django==4.0.3
django-qr-code==3.0.0
gunicorn==20.1.0
qrcode==7.3.1
segno==1.4.1
sqlparse==0.4.2

My Procfile:

web: gunicorn qrcode.wsgi

qrcode is the name of the folder containing the settings and wsgi file.

I have tried:

  • adding qr_code to the requirements
  • reinstalling the qr_code module
  • rewriting the requirements.txt via pip freeze > requirements.txt and then committing
ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257
  • Welcome to Stack Overflow. [Please don't post screenshots of text](https://meta.stackoverflow.com/a/285557/354577). They can't be searched or copied, or even consumed by users of adaptive technologies like screen readers. Instead, paste the code as text directly into your question. If you select it and click the `{}` button or Ctrl+K the code block will be indented by four spaces, which will cause it to be rendered as code. – ChrisGPT was on strike Mar 14 '22 at 12:16
  • You use both `qr_code` and `qrcode` in your question. I guess one of these is the name of your Django project? Which is it? Please show the list of files in the root directory of your project and the files in your `qrcode/` or `qr_code/` folder. (Side note: if this is your own project name you should _not_ add it to your `requirements.txt` file. That file is only for third-party dependencies.) – ChrisGPT was on strike Mar 14 '22 at 12:18
  • Thank you for your answer.The name of my Djangoproject is Qrprojekt wich contains the following folders: qrcode and sendqr while qrcode is the folder containing the settings.py and wsgi file There is no qr_code folder in my project. – KaisoTheKid Mar 14 '22 at 12:25

1 Answers1

0

It looks like you have a typo in your settings.py. Something like this:

INSTALLED_APPS = [
    # ...
    'qr_code',
    # or
    'qr_code.apps.Qr_CodeConfig',
]

If your app is called qrcode, that's what should be in INSTALLED_APPS:

INSTALLED_APPS = [
    # ...
    'qrcode',
    # or
    'qrcode.apps.QrCodeConfig',
]

I see that you are also depending on the qrcode module from PyPI. Having two modules named qrcode in the same project is likely to create problems. For example, when you import qrcode you'll probably get your own app, not the library you're looking for.

Assuming that's true, consider naming your own app something different.

ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257