【发布时间】:2017-05-05 18:08:40
【问题描述】:
在我的 Google Compute Engine 实例上,我一直在尝试按照以下步骤设置我的应用服务器 (uWSGI):
- cd /path/to/project/directory
- 在 virtual_env 上工作
- uwsgi --ini uwsgi.ini
每次我初始化 uWSGI 时,都会抛出以下错误(下面是更广泛的日志):
ImportError: No module named '"adtor'
unable to load app 0 (mountpoint='') (callable not found or import error)
我能够单独运行开发服务器(python manage.py runserver)。奇怪的是,在我的 django 应用程序名称之前有一个额外的双引号 ("),但我无法在代码、.ini、虚拟 env 挂钩(例如 postactivate)中找到任何额外双引号的实例。除此之外,我'无法找到潜在的罪魁祸首;我假设它在我的 .ini 文件中或未正确安装某些第三方库。
“点冻结”:
appdirs==1.4.3
Django==1.8.5
django-filter==1.0.2
django-model-utils==3.0.0
djangorestframework==3.6.2
mysqlclient==1.3.10
packaging==16.8
pyparsing==2.2.0
six==1.10.0
uWSGI==2.0.15
uwsgi.ini
[uwsgi]
socket=127.0.0.1:8000
stats=127.0.0.1:9191
http-timeout=1800
uid=www-data
gid=www-data
virtualenv=/home/tor/.virtualenvs/adtor_prod
home=/home/tor/.virtualenvs/adtor_prod
chdir=/srv/django/adtor_project/prime
module=adtor.wsgi:application
master=true
vacuum=true
thunder-lock=true
pidfile=/tmp/project-master.pid
daemonize=/var/log/uwsgi/adtor-blog.log
threads=2
enable-threads=true
for-readline = /etc/srv/vars.txt
env = %(_)
endfor =
日志:
*** Starting uWSGI 2.0.15 (64bit) on [Fri May 5 16:00:56 2017] ***
compiled with version: 4.8.4 on 02 May 2017 17:47:17
os: Linux-4.4.0-75-generic #96~14.04.1-Ubuntu SMP Thu Apr 20 11:06:30 UTC 2017
nodename: instance-1
machine: x86_64
clock source: unix
detected number of CPU cores: 1
current working directory: /srv/django/adtor_project
writing pidfile to /tmp/project-master.pid
detected binary path: /home/tor/.virtualenvs/adtor_prod/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
chdir() to /srv/django/adtor_project/prime
your processes number limit is 2257
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: enabled
uwsgi socket 0 bound to TCP address 127.0.0.1:8000 fd 3
Python version: 3.4.3 (default, Nov 17 2016, 01:12:14) [GCC 4.8.4]
Set PythonHome to /home/tor/.virtualenvs/adtor_prod
Python main interpreter initialized at 0x1a02ab0
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 166112 bytes (162 KB) for 2 cores
*** Operational MODE: threaded ***
Traceback (most recent call last):
File "./adtor/wsgi.py", line 16, in <module>
application = get_wsgi_application()
File "/home/tor/.virtualenvs/adtor_prod/lib/python3.4/site-packages/django/core/wsgi.py", line 14, in get_wsgi_application
django.setup()
File "/home/tor/.virtualenvs/adtor_prod/lib/python3.4/site-packages/django/__init__.py", line 17, in setup
configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
File "/home/tor/.virtualenvs/adtor_prod/lib/python3.4/site-packages/django/conf/__init__.py", line 48, in __getattr__
self._setup(name)
File "/home/tor/.virtualenvs/adtor_prod/lib/python3.4/site-packages/django/conf/__init__.py", line 44, in _setup
self._wrapped = Settings(settings_module)
File "/home/tor/.virtualenvs/adtor_prod/lib/python3.4/site-packages/django/conf/__init__.py", line 92, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/home/tor/.virtualenvs/adtor_prod/lib/python3.4/importlib/__init__.py", line 109, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ImportError: No module named '"adtor'
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: 8753)
spawned uWSGI worker 1 (pid: 8755, cores: 2)
*** Stats server enabled on 127.0.0.1:9191 fd: 10 ***
【问题讨论】:
-
这个额外的
"故事看起来像The double quotes were not proper double quotes,即”而不是"。即使显然不是,因为您的回溯确实显示了真正的双引号。 -
看来我正确使用了双引号。我把它改成单引号,收到错误:ImportError: No module named "'adtor" 好像多余的单/双引号与它无关
-
你的
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "adtor.settings")是否也正确地写在了wsgi.py中? -
是的。我一直在使用默认的 wsgi.py 文件,如中,对该文件进行了零更改
-
您曾经能够运行您的生产站点吗?
标签: django google-compute-engine uwsgi