1.安装步骤:
tar xvzf tornado-3.2.tar.gz
cd tornado-3.2
python setup.py build
sudo python setup.py install PS:
<1>这里我用的是python3.2版本,系统python默认的是python2.6版本,因此在最后两步实际运行的命令是:
  python3.2 setup.py build ; sudo python3.2 setup.py install
<2>疑问?:这里安装好的tornado在哪个目录下,是在自己解压的目录下吗?如果是,对解压安装的目录有没有什么要求?
  --tornado安装在了 /usr/lib/python3.2/site-packages/ 目录下 2.简单程序 hello_1.py 示例:
import tornado.ioloop
import tornado.web class MainHandler(tornado.web.RequestHandler):
def get(self):
self.write("Hello, world") application = tornado.web.Application([
(r"/", MainHandler),]) if __name__ == "__main__":
application.listen(8888)
tornado.ioloop.IOLoop.instance().start()
运行以上程序出现如下错误:

错误1:

-bash-4.2$ python3.2 hello_1.py
File "hello_1.py", line 15
application.listen(8888)
           ^
IndentationError: unindent does not match any outer indentation level

此类错误属于低级错误,因为我是直接复制的代码,主要原因就是TAB键和空格混搭使用

当前用的文本编辑器Notepad++,可以显示所有的字符的
设置方法:视图 -> 显示符号 -> 显示空格与制表符

具体可参加文章来源:http://www.crifan.com/python_syntax_error_indentationerror/comment-page-1/

错误2:

python2.6版本中:
-bash-4.2$ python
Python 2.6.7 (r267:88850, Nov 16 2013, 08:26:47)
[GCC 4.4.4] on sunos5
Type "help", "copyright", "credits" or "license" for more information.
>>> import multiprocessing

python3.2版本中:
-bash-4.2$ python3.2
Python 3.2.5 (default, Nov 16 2013, 04:35:19)
[GCC 4.4.4] on sunos5
Type "help", "copyright", "credits" or "license" for more information.
>>>
KeyboardInterrupt
>>> import multiprocessing
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.2/multiprocessing/__init__.py", line 83, in <module>
import _multiprocessing
ImportError: No module named _multiprocessing

在运行示例代码时也会报错 ImportError: No module named _multiprocessing

解决方法:

A quickfix is to create a file in your app's root named `_multiprocessing.py' with
the contents: import multiprocessing This way it's possible to import the _multiprocessing module. 解决方法来源:https://code.google.com/p/googleappengine/issues/detail?id=1504
PS:创建文件 _multiprocessing.py 文件内容为:import multiprocessing 将该文件添加到目录 /usr/lib/python3.2/multiprocessing/ 即可成功运行
修改完以上错误,执行命令curl http://localhost:8888/则显示出:
Hello, world
05-19 03:32