Answer the question
In order to leave comments, you need to log in
UWSGI not running django project out of the box?
Deploying a Django project on Nginx + uWSGI. I ran into a strange error, the wsgi test file starts up normally, but the dzhang one, which comes straight from the box, does not want to start for some reason.
Here is the content of the test file:
def application(env, start_response):
start_response('200 OK', [('Content-Type','text/html')])
return [b"Hello World"]
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'testproject.settings')
application = get_wsgi_application()
Traceback (most recent call last):
File "wsgi.py", line 16, in <module>
application = get_wsgi_application()
File "/usr/local/lib/python3.6/dist-packages/django/core/wsgi.py", line 12, in get_wsgi_application
django.setup(set_prefix=False)
File "/usr/local/lib/python3.6/dist-packages/django/__init__.py", line 19, in setup
configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
File "/usr/local/lib/python3.6/dist-packages/django/conf/__init__.py", line 82, in __getattr__
self._setup(name)
File "/usr/local/lib/python3.6/dist-packages/django/conf/__init__.py", line 69, in _setup
self._wrapped = Settings(settings_module)
File "/usr/local/lib/python3.6/dist-packages/django/conf/__init__.py", line 170, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 941, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'testproject'
Answer the question
In order to leave comments, you need to log in
If suddenly someone has the same problem with python versions, then on ubuntu the versions are changed with the following command
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.8 1
You run not through a virtual environment, but really in a real system, and, of course, there is nothing there. You need to run something like this: .venv/bin/python myscript.py
By the way, you can also install packages on the environment like this: .venv/bin/pip install django
But this is for the normal launch of one command without activating the environment.
As for the server, try reading this:
Nginx + uWSGI + virtualenv + Django | Recipes | DJ...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question