无法部署django应用-ImportError:没有名为django.core.wsgi的模块

时间:2019-12-09 16:40:36

标签: python django deployment wsgi

因此,基本上,我想在我的国家/地区托管上部署django(wa)应用程序。这是我所做的:

  1. 我使用FTP将项目文件复制到/home/ketohubp/KetoHub.pl。
  2. 我创建并输入了venv(source venv/bin/activate)。
  3. 我尝试使用以下命令部署应用程序:
    uwsgi --http 127.0.0.1:8054 --chdir /home/ketohubp/KetoHub.pl --wsgi-file /home/ketohubp/KetoHub.pl/wsgi.py --master --processes 1 --workers 1 --threads 1 --daemonize=/home/ketohubp/KetoHub.pl/log.txt
  1. 我检查了是否安装了django:
    (venv) ketohubp@hs7:~$ django-admin version 2.2.8
  1. 我尝试使用fuser -k 8054/tcp杀死并重新生成uwsgi进程
  2. 我检查了log.txt包含的内容:
    *** Starting uWSGI 2.0.18 (64bit) on [Mon Dec  9 17:37:19 2019] ***
    compiled with version: 6.3.0 20170516 on 21 November 2019 19:38:29
    os: Linux-4.9.0-8-amd64 #1 SMP Debian 4.9.144-3.1 (2019-02-19)
    nodename: hs7.linux.pl
    machine: x86_64
    clock source: unix
    pcre jit disabled
    detected number of CPU cores: 8
    current working directory: /home/ketohubp/KetoHub.pl
    detected binary path: /home/ketohubp/venv/bin/uwsgi
    chdir() to /home/ketohubp/KetoHub.pl
    your processes number limit is 256771
    your memory page size is 4096 bytes
    detected max file descriptor number: 1024
    lock engine: pthread robust mutexes
    thunder lock: disabled (you can enable it with --thunder-lock)
    uWSGI http bound on 127.0.0.1:8054 fd 4

    uwsgi socket 0 bound to TCP address 127.0.0.1:37743 (port auto-assigned) fd 3
    Python version: 3.5.3 (default, Sep 27 2018, 17:25:39)  [GCC 6.3.0 20170516]
    Python main interpreter initialized at 0x55be3db1eb40
    python threads support enabled
    your server socket listen backlog is limited to 100 connections
    your mercy for graceful operations on workers is 60 seconds
    mapped 145840 bytes (142 KB) for 1 cores
    *** Operational MODE: single process ***
    failed to open python file /home/ketohubp/KetoHub.pl/wsgi.py
    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: 16988)
    spawned uWSGI worker 1 (pid: 16989, cores: 1)
    spawned uWSGI http 1 (pid: 16990)
  1. 我联系了托管支持人员以查看服务器错误:
    [Wed Dec 04 20:53:06.200086 2019] [wsgi:error] [pid 4914:tid 140320264152832] [remote 193.239.126.103:49538] mod_wsgi (pid=4914): Failed to exec Python script file '/home/ketohubp/KetoHub.pl/Wagtail_Django_Static_Blog/wsgi.py'.
    [Wed Dec 04 20:53:06.200171 2019] [wsgi:error] [pid 4914:tid 140320264152832] [remote 193.239.126.103:49538] mod_wsgi (pid=4914): Exception occurred processing WSGI script '/home/ketohubp/KetoHub.pl/Wagtail_Django_Static_Blog/wsgi.py'.
    [Wed Dec 04 20:53:06.200187 2019] [wsgi:error] [pid 4914:tid 140320264152832] [remote 193.239.126.103:49538] Traceback (most recent call last):
    [Wed Dec 04 20:53:06.200196 2019] [wsgi:error] [pid 4914:tid 140320264152832] [remote 193.239.126.103:49538]   File "/home/ketohubp/KetoHub.pl/Wagtail_Django_Static_Blog/wsgi.py", line 12, in <module>
    [Wed Dec 04 20:53:06.200222 2019] [wsgi:error] [pid 4914:tid 140320264152832] [remote 193.239.126.103:49538]     from django.core.wsgi import get_wsgi_application
    [Wed Dec 04 20:53:06.200231 2019] [wsgi:error] [pid 4914:tid 140320264152832] [remote 193.239.126.103:49538] ImportError: No module named django.core.wsgi
  1. 我再次联系托管服务以检查配置文件:
     DocumentRoot /home/ketohubp/KetoHub.pl
     WSGIScriptAlias / /home/ketohubp/KetoHub.pl/Wagtail_Django_Static_Blog/wsgi.py
     WSGIDaemonProcess ketohub.pl processes=2 threads=15 display-name=%{GROUP}
     WSGIProcessGroup ketohub.pl

     <directory /home/ketohubp/KetoHub.pl>
       SetHandler wsgi-script
       AllowOverride all
       Require all granted
       Options ExecCGI FollowSymlinks
       <Files wsgi.py>
       Require all granted
       </Files>
     </directory>

     Alias /static/ /home/ketohubp/KetoHub.pl/Wagtail_Django_Static_Blog/static/

     <Directory /home/ketohubp/KetoHub.pl/Wagtail_Django_Static_Blog/static>
      Require all granted
     </Directory>

1 个答案:

答案 0 :(得分:0)

我明白了,问题出在“ --wsgi文件/home/ketohubp/KetoHub.pl/Wagtail_Django_Static_Blog/wsgi.py”错误路径。