Django Python3/uWSGI快速启动时出现语法错误

Django Python3/uWSGI快速启动时出现语法错误,django,python-3.x,ubuntu-14.04,uwsgi,Django,Python 3.x,Ubuntu 14.04,Uwsgi,我浪费了很多时间,但找不到解决办法。请求帮助。 我使用ubuntu服务器14.04,通过以下方式设置uwsgi: pip3 install uwsgi 然后我创建test.py: def application(env, start_response): start_response('200 OK', [('Content-Type','text/html')]) return [b"Hello World"] 在我跑步之后: uwsgi --http :8001 --ws

我浪费了很多时间,但找不到解决办法。请求帮助。 我使用ubuntu服务器14.04,通过以下方式设置uwsgi:

pip3 install uwsgi
然后我创建test.py:

def application(env, start_response):
    start_response('200 OK', [('Content-Type','text/html')])
    return [b"Hello World"]
在我跑步之后:

uwsgi --http :8001 --wsgi-file test.py
它表明:

*** Starting uWSGI 2.0.12 (64bit) on [Sat Mar 26 13:06:41 2016] ***
compiled with version: 4.8.4 on 26 March 2016 09:06:13
os: Linux-3.13.0-65-generic #106-Ubuntu SMP Fri Oct 2 22:08:27 UTC 2015
nodename: iZ282na6z2kZ
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 1
current working directory: /home
detected binary path: /usr/local/bin/uwsgi
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 15834
your memory page size is 4096 bytes
detected max file descriptor number: 65535
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uWSGI http bound on :8001 fd 4
spawned uWSGI http 1 (pid: 24498)
uwsgi socket 0 bound to TCP address 127.0.0.1:57629 (port auto-assigned) fd 3
Python version: 3.4.3 (default, Oct 14 2015, 20:31:36)  [GCC 4.8.4]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x16fa3b0
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 72760 bytes (71 KB) for 1 cores
*** Operational MODE: single process ***
  File "test.py", line 3
    return [b'Hello World']
         ^
SyntaxError: invalid syntax
failed to parse file test.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 worker 1 (and the only) (pid: 24497, cores: 1)
为什么python3会出现语法错误


p.S对不起我的英语:p

你确定你在这里发布了你的实际代码而没有简化它吗?我看不出这个有语法错误。是的,这是实际的代码,这就是为什么我很困惑的原因。我一步一步地遵循uWSGI文件。使用pip3安装uwsgi,是否出错?:(@Selcuk注意到错误显示为第3行,因此函数是文件中的第一件事,这就是导致语法错误的原因。@JoshuaHoo,你找到了吗?你能用普通的python解释器运行代码吗?文件中可能有非打印字符吗?