0

While trying to deploy my django project on my Gandy hosting server, while starting running uwsgi, the uwsgi.log shows an error

ModuleNotFoundError: No module named 'django'

while executing the following line from my wsgi.py file

from django.core.wsgi import get_wsgi_application

here is the full wsgi file:

import sys
import os
import os.path

sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__),
                                                'projectname')))
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'projectname.settings')
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

from what I understand, django is not installed in my virtual environment, but it is listed in my requirements.txt file

Django==3.0.6
django-background-tasks==1.2.5
django-compat==1.0.15
django-extensions==3.0.3
django-mathfilters==1.0.0

Can anyone pin point where I am missing something?

Tibibs
  • 71
  • 1
  • 8
  • Does this answer your question: [How to use requirements.txt to install all dependencies in a python project](https://stackoverflow.com/questions/41457612/how-to-use-requirements-txt-to-install-all-dependencies-in-a-python-project) – Jaydeep Aug 05 '20 at 17:48
  • I have actually restarted a new virtual environment on my local machine, and made sure everything runs fine with runserver. I have generated a new requirements file asgiref==3.2.10 Django==3.1 pkg-resources==0.0.0 pytz==2020.1 sqlparse==0.3.1 but still the same problem, django can't be found on the remote server – Tibibs Aug 05 '20 at 18:09

1 Answers1

0

I realise you've probably moved on from this now!

In case others hit the same issue, you need to deploy your code, not just upload it, for the Gandi Python environment to read requirements.txt and build your code.

See https://docs.gandi.net/en/web_hosting/connection/git.html?highlight=deploy#deploy-your-code

  • the user is sharing the server logs clearly. The code has been deployed, but the dependencies are not installed yet. Your comment does not go in the right direction – sogeking Jan 08 '23 at 08:49
  • You might be right. Just for background, though, I was hitting similar issues to the ones he described when I uploaded my code via FTP (naively expecting the server to run the code as a post-upload action). Committing the code via git then running the ssh deploy command fixed the issue. – Jamie Keene Apr 27 '23 at 14:16