当我将Django应用程序从python2.7迁移到python3.6时,出现500 Internal Server Error。我创建了一个新的virtualenv,并分别创建了所有应用程序。 virtualenv在uwsgi.ini文件中定义
home = /home/netadc/.venvs1/netadc
我已经使用pip3.6安装了所有软件包。我不确定我缺少什么。 uwsgi中的每个配置在工作时都与python2.7相同。我正在使用uwsgi 2.0.13。我也重新启动了Nginx。我无法找到适用于python3的单独uwsgi吗?套接字权限也与以前相同。请帮忙。
启动wsgi的命令是:-
/home/netadc/.venvs1/netadc/bin/uwsgi --ini /home/netadc/apps/netadc/netadc/uwsgi/netadc_uwsgi.ini --enable-threads
在wsgi日志中,我看到了:-
--- no python application found, check your startup logs for errors ---
[pid: 13634|app: -1|req: -1/3] x.x.x.x () {42 vars in 1029 bytes} [Mon Dec 17 09:04:40 2018] GET /netadc/home => generated 21 bytes in 0 msecs (HTTP/1.1 500)
nginx中的访问日志显示:-
x.x.x.x - - [17/Dec/2018:09:05:43 -0700] "GET /netadc/home HTTP/1.1" 500 32
nginx错误日志中什么也没有。
当我执行manage.py shell时,我会看到:-
ImportError: bad magic number in 'lib': b'\x03\xf3\r\n'
我删除了所有.pyc文件,但有时manage.py shell挂起,有时打开正常。但是再过一段时间后,我会得到上面的幻数错误。
当我在使用python2.7的uwsgi.ini文件中将virtualenv恢复回我以前的virtualenv时,我在uwsgi上收到一些错误日志。
home = /home/netadc/.venvs/netadc
日志:-
File "./ivpn/rest_appviewx.py", line 29
print('Server IP has NAT already. So no QIP update needed.', end=' ')
^
SyntaxError: invalid syntax
我的uwsgi ini文件:-
[uwsgi]
#uid = nginx
#gid = nginx
# Django-related settings
env = HTTPS=on
# the base directory (full path)
chdir = /home/netadc/apps/netadc
# Django's wsgi file
module = netadc.wsgi
# the virtualenv (full path)
home = /home/netadc/.venvs1/netadc
pythonpath = /home/netadc/.venvs1/netadc/bin/python3.6
PythonHome = /home/netadc/.venvs1/netadc/
# master
master = true
# maximum number of worker processes
processes = 10
buffer-size = 65536
# the socket (use the full path to be safe
socket = /home/netadc/apps/netadc/netadc/uwsgi/tmp/netadc.sock
# read post data by default
post-buffering = 1
# ... with appropriate permissions - may be needed
#chmod-socket = 666
# daemonize
daemonize = true
# logging
logger =
file:/home/netadc/apps/netadc/netadc/uwsgi/tmp/netadc_uwsgi.log
# clear environment on exit
vacuum = true