33👍
The problem was that the system-wide python version linked to uwsgi needs to be the same as the one of the virtualenv, which, I think, is a very stupid thing.
EDIT April 2021: I now recommend using gunicorn, which does not have this problem
3👍
In my case it was using the system wide uwsgi, I’m working using a virtualenv so if I execute
$ which uwsgi
I got /usr/local/python3.6/bin/uwsgi
As Valentin Iovene suggests you need to use the uwsgi from your virtual environment
My directories structure is something like this:
~/Env
--/app
--/bin
----/....
----/uwsgi <-- This should be the good one
----/...
--/include
--/lib
(The app directory is where my django app resides)
In my case uwsgi file hasn’t execution permissions so I only executed:
$ chmod +x ~/Env/bin/uwsgi
Finally under my app directory I executed the uwsgi command as follows:
../bin/uwsgi --http :8000 --module app.wsgi
Now I can see my app working now 🙂
I’m following this guide: https://uwsgi-docs.readthedocs.io/en/latest/tutorials/Django_and_nginx.html
Next steps are configuring nginx and https…
I know it’s a late response but hope this helps and shared what worked for me.
- Using annotate or extra to add field of foreignkey to queryset ? (equivalent of SQL "AS" ?)
- Linking django and mysql containers using docker-compose
- How to test django application placed in subfolder?
- UWSGI listen queue of socket full
- Why do I need the DJANGO_SETTINGS_MODULE set?
2👍
I also found some possible pitfalls I want to share:
- check, if
virtualenv
(which is the same asvenv
,pyhome
andhome
) is set to that directory, that contains thebin
,include
,lib
, … directories - check, if the user (
uid
) can read the files in your project and the libs in virtual environment (this ends in aModuleNotFoundError
instead of a permission error) - use
need-app
to exit on failures (this helps for debugging and should be default imho) - use
strict
to avoid typos in config (this should also be default…) -
if your
test.py
runs, try to import modules of your project and your virtual environment, to test if that works. It also helps to add aimport sys print(sys.path)
You can also copy the printed sys.path
, open a python shell and set sys.path
to the same value and try to import the desired wsgi module.
- Django parallel testing: Test processes incorrectly accessing test databases
- Most elegant approach for writing JSON data to a relational database using Django Models?
- Django aggregate Count only True values
1👍
look at this at gsd.ini
:
virtualenv = /home/toogy/.pyenv/versions/%n
have you install django
under this virtualenv?
- "<Model> with this <field> already exist" on PUT call – Django REST Framework
- Django queryset exclude() with multiple related field clauses
- Raise ValidationError from pre_save receiver function?
- How to use custom managers in chain queries?
- No connection could be made because the target machine actively refused it (Django)
1👍
When I execute:
uwsgi --socket client_book.sock --module myproject.wsgi --chmod-socket=666
in the directory ~/
, and I would get the following error:
ModuleNotFoundError: No module named 'myproject.wsgi'
The solution was to run the command one layer deeper in the directory ~/myproject
This way, uwsgi
was able to find myproject.wsgi
.
This was what fixed it for me.
- "Show all" for more than 200 items in Django Admin
- How to maintain different country versions of same language in Django?
- Django admin: how to sort column by custom method
- Django channels and socket.io-client