Try:

gunicorn --bind ip:port wsgi:application

Make sure you run it from the directory where manage.py is located.
Regards,
M

On Sun, Sep 3, 2017 at 9:04 AM, Jonathan Cheng <jonathan950...@gmail.com>
wrote:

> I use Python3.5.2 Django1.9
>
> I use `python -m venv venv/weather_station` to create virtual evnironment
> (/home/user/venv)
>
> This is my project tree in Ubuntu /home/user/myproject:
> (`export project=/home/user/myproject`)
>
>     myproject
>    |
>    ├── gunicorn.conf.py
>    ├── static
>    │   ├── admin
>    └── weather_station
>        ├── base
>        │   ├── migrations
>        │   ├── static
>        │   └── templates
>        └── weather_station
>            ├── __init__.py
>            ├── wsgi.py
>            ├── urls.py
>            ├── settings
>                ├── base.py
>                ├── production.py
> 在此輸入代碼...
>
> __init__.py:
> import pymysql
>     pymysql.install_as_MySQLdb()
> wsgi.py
> import os
>
>     from django.core.wsgi import get_wsgi_application
>
>     os.environ.setdefault("DJANGO_SETTINGS_MODULE",
> "weather_station.settings.production")
>
>     application = get_wsgi_application()
> The partial in the settings.base.py:
> BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.
> path.abspath(__file__))))
>
>     ROOT_URLCONF = 'weather_station.urls'
>
>     WSGI_APPLICATION = 'weather_station.wsgi.application'
>
>     STATIC_URL = '/static/'
> In the partial of settings.production.py:
> from .base import *
>
>     DEBUG = False
>
>     STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), 'static')
>
>     MEDIA_ROOT = os.path.join(os.path.dirname(BASE_DIR), 'media')
> gunicorn.conf.py:
> import os
>
>     bind = '127.0.0.1:8080'
>     worders = (os.sysconf('SC_NPROCESSORS_ONLN') * 2) + 1
>     loglevel = 'error'
>     command = '/home/user/venv/weather_station/bin/gunicorn'
>     pythonpath = '/home/user/myproject/weather_station'
>
> And in the /etc/nginx/sites-available/weather.conf:
>
> upstream weather_station {
>     server 127.0.0.1:8080;
> }
>
>     server {
>         listen 80 default_server;
>         listen 443 default ssl;
>         server_name http://my_ip;
>         client_max_body_size 10M;
>         keepalive_timeout    15;
>
>         location /static/ {
>             alias           /$project/static/;
>         }
>         location /media/ {
>             alias           /$project/media/;
>         }
>
>         location / {
>             proxy_redirect      off;
>             proxy_set_header    Host                    $host;
>             proxy_set_header    X-Real-IP               $remote_addr;
>             proxy_set_header    X-Forwarded-For
> $proxy_add_x_forwarded_for;
>             proxy_set_header    X-Forwarded-Protocol    $scheme;
>             proxy_pass          http://myproject;
>
> When I the follwoing command under myproject
> gunicorn -c gunicorn.conf.py weather_station.weather_station.wsgi
>
>
>
> It showed `ImportError: No module named 'weather_station.settings'`
>
> Does any know the reason ?
>
>
> it successfully weather_station.wsgi.
>
> But the new error is  `ImportError: No module named
> 'weather_station.settings'`
>
> detailed log
>
>
>  File "/home/user/myproject/weather_station/weather_station/wsgi.py",
> line 17, in <module>
>         application = get_wsgi_application()
>       File "/home/user/.local/lib/python3.5/site-packages/
> django/core/wsgi.py", line 13, in get_wsgi_application
>         django.setup()
>       File "/home/user/.local/lib/python3.5/site-packages/
> django/__init__.py", line 17, in setup
>         configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
>       File "/home/user/.local/lib/python3.5/site-packages/
> django/conf/__init__.py", line 55, in __getattr__
>         self._setup(name)
>       File "/home/user/.local/lib/python3.5/site-packages/
> django/conf/__init__.py", line 43, in _setup
>         self._wrapped = Settings(settings_module)
>       File "/home/user/.local/lib/python3.5/site-packages/
> django/conf/__init__.py", line 99, in __init__
>         mod = importlib.import_module(self.SETTINGS_MODULE)
>       File "/usr/lib/python3.5/importlib/__init__.py", line 126, in
> import_module
>         return _bootstrap._gcd_import(name[level:], package, level)
>     ImportError: No module named 'weather_station.settings'
>
>
>
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/87a81098-2124-4702-a429-4f161cd055d8%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/87a81098-2124-4702-a429-4f161cd055d8%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CANoUts5cinSPtkRFXeOa8s%3Dg1OD4Jt86w1MZJey7y_fnCTMWLQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to