如何修复OSError:[Errno 48]地址已在使用中

时间:2016-01-23 20:02:43

标签: python django

我正在使用此book

使用此代码

    @classmethod
def setUpClass(cls):
    for arg in sys.argv:
        if 'liveserver' in arg:
            cls.server_url = 'http://' + arg.split('=')[1]
            return
        super().setUpClass()
        cls.server_url=cls.live_server_url

当我尝试使用python3 manage.py test functional_tests启动我的功能测试时出现此错误

ERROR: setUpClass (functional_tests.tests.NewVisitorTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/USERNAME/Desktop/dev/tddwp/chap8/functional_tests/tests.py", line 14, in setUpClass
    super().setUpClass()
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/django/test/testcases.py", line 1189, in setUpClass
    raise cls.server_thread.error
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/django/test/testcases.py", line 1091, in run
    (self.host, port), QuietWSGIRequestHandler)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/django/core/servers/basehttp.py", line 117, in __init__
    super(WSGIServer, self).__init__(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/socketserver.py", line 430, in __init__
    self.server_bind()
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/django/core/servers/basehttp.py", line 121, in server_bind
    super(WSGIServer, self).server_bind()
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/wsgiref/simple_server.py", line 50, in server_bind
    HTTPServer.server_bind(self)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/http/server.py", line 135, in server_bind
    socketserver.TCPServer.server_bind(self)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/socketserver.py", line 441, in server_bind
    self.socket.bind(self.server_address)
OSError: [Errno 48] Address already in use

我试过了 *重新启动我的机器 *从github下载repo并从那里运行以消除我可能做出的任何无意的错误 *使用lsof查看我是否可以找到它正在运行的端口并将其终止(我找不到它)。

我没有想法。任何人都知道可能出错了什么?

1 个答案:

答案 0 :(得分:0)

使用其他端口:D。根据furas和Keith