刚开始学习web.py,只是运行了helloworld的简单demo,但是在pycharm中只要run,就会报错,错误信息如下:
/usr/bin/python2.7 /Users/apple/PycharmProjects/webpy/HelloWorld.py
Traceback (most recent call last):
File "/Users/apple/PycharmProjects/webpy/HelloWorld.py", line 19, in <module>
app.run()
File "/Users/apple/Library/Python/2.7/lib/python/site-packages/web/application.py", line 313, in run
return wsgi.runwsgi(self.wsgifunc(*middleware))
File "/Users/apple/Library/Python/2.7/lib/python/site-packages/web/wsgi.py", line 59, in runwsgi
return httpserver.runsimple(func, server_addr)
File "/Users/apple/Library/Python/2.7/lib/python/site-packages/web/httpserver.py", line 157, in runsimple
server.start()
File "/Users/apple/Library/Python/2.7/lib/python/site-packages/web/wsgiserver/__init__.py", line 1753, in start
raise socket.error(msg)
socket.error: No socket could be created
http://0.0.0.0:8080/
出现上面错误的原因是端口8080被占用。
修改方法如下:
在mac终端,查看8080端口使用的情况:sudo lsof -i :8080
上面情况说明有两个进程占用了8080端口,需要杀死进程即可。
杀死进程:kill PID