Python Forum
Problems configuring and running uWSGI
Thread Rating:
  • 2 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problems configuring and running uWSGI
#1
Im trying to follow a tutorial to deploy a simple blog with Django and running into some problems with uwsgi.
So far I have done the following (as per the tutorial instructions):

Moved the contents of settings.py to base.py 
Created local.py and pro.py files in a new settings folder for local and production environments 
Installed PSQL and created a user and db Installed WSGI

I have then run uwsgi with this command

 
uwsgi --module=codego.wsgi:application --  env=DJANGO_SETTINGS_MODULE=codego.settings.pro --   http=127.0.0.1:80 --   virtualenv=/Users/david/documents/projects/django/codego   /venv/ --thunder-lock
I am then able to open my django site locally where it loads with no css

I then created the following uwsgi.ini file in a directory labeled ‘config’ in the main project folder


[uwsgi]
#variables
projectname = codego
base = /Users/david/documents/projects/django/codego/
 #configuration
master = true
virtualenv =     /Users/david/documents/projects/django/codego/venv/
pythonpath = %(base)
chdir = %(base)
env = DJANGO_SETTINGS_MODULE=%   (codego).settings.pro
module = codego.wsgi:application
socket = /tmp/%(codego).sock
finally I run this command


uwsgi –ini config/uwsgi.ini
and then I get the error:


ImportError: No module named 'codego.wsgi'

unable to load app 0 (mountpoint='') (callable not found     or import error)
and this is the full output:


[uWSGI] getting INI configuration from config/uwsgi.ini
*** Starting uWSGI 2.0.13.1 (64bit) on [Wed Sep 28    19:40:26 2016] ***
compiled with version: 4.2.1 Compatible Apple LLVM   7.0.2 (clang-700.1.81) on 17 September 2016 14:57:57
os: Darwin-14.5.0 Darwin Kernel Version 14.5.0: Mon  Aug 29 21:14:16 PDT 2016; root:xnu-  2782.50.6~1/RELEASE_X86_64
nodename: Davids-MacBook-Air.local
machine: x86_64
clock source: unix
detected number of CPU cores: 4
current working directory:   /Users/david/Documents/projects/django/codego/codego
detected binary path:   /Users/david/Documents/projects/django/codego/venv/bin/   uwsgi
!!! no internal routing support, rebuild with pcre support  !!!
chdir() to  /Users/david/documents/projects/django/codego/
your processes number limit is 709
your memory page size is 4096 bytes
detected max file descriptor number: 256
lock engine: OSX spinlocks
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to UNIX address /tmp/%    (codego).sock fd 3
Python version: 3.5.1 (default, Dec  7 2015, 21:59:08)     [GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.1.76)]
Set PythonHome to     /Users/david/documents/projects/django/codego/venv/
*** Python threads support is disabled. You can enable it    with --enable-threads ***
Python main interpreter initialized at 0x7f96a9d00c00
your server socket listen backlog is limited to 100   connections
your mercy for graceful operations on workers is 60  seconds
mapped 145520 bytes (142 KB) for 1 cores
*** Operational MODE: single process ***
added /Users/david/documents/projects/django/codego/    to pythonpath.
ImportError: No module named 'codego.wsgi'
unable to load app 0 (mountpoint='') (callable not found    or import error)
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 2935)
spawned uWSGI worker 1 (pid: 2936, cores: 1)
it seems that there’s a problem with the wsgi file being loaded but its in the right place. This is the path to the file also:


  /Users/david/Documents/projects/django/codego/codego/codego/wsgi.py
and this is the contents of it:


import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE",   "codego.settings")

application = get_wsgi_application()
also if I try to run wigs.py I get a long output of errors, this is a sample


File "wsgi.py", line 16, in <module>
    application = get_wsgi_application()
  File   "/Users/david/Documents/projects/django/codego/venv/lib/ python3.5/site-packages/django/core/wsgi.py", line 13, in    get_wsgi_application
    django.setup(set_prefix=False)
and


return _bootstrap._gcd_import(name[level:], package,   level)
  File "<frozen importlib._bootstrap>", line 986, in  _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in    _find_and_load

ImportError: No module named 'codego'
what am I doing wrong here?

thanks
Reply
#2
Hello,

Have you seen this


Larz60+
Reply
#3
Quote: /Users/david/Documents/projects/django/codego/codego/codego/wsgi.py
Why is it nested so deeply within itself? Wouldn't that mean you'd need to do something like "from codego.codego import codego"?
Reply
#4
hello and sorry for the lack of response here, I setup using nginx on Digital Ocean in the end, thanks for the responses though
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to set up uwsgi and nginx? Stas43 2 1,181 Apr-21-2023, 10:51 AM
Last Post: Stas43
  Python flask uwsgi nginx docker mfaridi 2 1,794 Sep-14-2022, 11:07 AM
Last Post: mfaridi
  run watchdog in flask app with uwsgi experimental 0 2,871 Apr-25-2020, 09:44 PM
Last Post: experimental
  flask to uwsgi threading issue batchenr 1 3,998 Jun-17-2019, 02:12 PM
Last Post: batchenr
  location settings for Django Uwsgi Nginx Configuration for production sandyman 0 2,943 Sep-15-2017, 09:08 AM
Last Post: sandyman
  Django+uWsgi unable to find "application" callable rosettas 3 11,851 Aug-24-2017, 01:41 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020