gpt4 book ai didi

python - "getaddrinfo() argument 1 must be string or None"在 Linux 上启动 dev_appserver.py 时出错

转载 作者:IT王子 更新时间:2023-10-29 01:20:36 25 4
gpt4 key购买 nike

在一段时间未使用 App Engine 后,我正在重新开始使用它。我使用的是 64 位 Linux Go 运行时版本 1.8.1。

我相信我正确地遵循了文档中的步骤,并且我相信我在做过去正确的事情,但是我在尝试启动 dev_appserver.py 时遇到了这个错误>:

$ dev_appserver.py .INFO     2013-07-11 07:24:45,919 sdk_update_checker.py:244] Checking for updates to the SDK.INFO     2013-07-11 07:24:46,230 sdk_update_checker.py:288] This SDK release is newer than the advertised release.WARNING  2013-07-11 07:24:46,443 simple_search_stub.py:955] Could not read search indexes from /tmp/appengine.batterybotinfo.darshan/search_indexesTraceback (most recent call last):  File "/home/darshan/bin/dev_appserver.py", line 182, in     _run_file(__file__, globals())  File "/home/darshan/bin/dev_appserver.py", line 178, in _run_file    execfile(script_path, globals_)  File "/home/darshan/software/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 695, in     main()  File "/home/darshan/software/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 688, in main    dev_server.start(options)  File "/home/darshan/software/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 659, in start    apis.start()  File "/home/darshan/software/google_appengine/google/appengine/tools/devappserver2/api_server.py", line 137, in start    super(APIServer, self).start()  File "/home/darshan/software/google_appengine/google/appengine/tools/devappserver2/wsgi_server.py", line 295, in start    if self._start_all_dynamic_port(host_ports):  File "/home/darshan/software/google_appengine/google/appengine/tools/devappserver2/wsgi_server.py", line 348, in _start_all_dynamic_port    server.start()  File "/home/darshan/software/google_appengine/google/appengine/tools/devappserver2/wsgi_server.py", line 194, in start    socket.SOCK_STREAM, 0, socket.AI_PASSIVE)TypeError: getaddrinfo() argument 1 must be string or None

My first thought was that I might be using an incorrect version of Python. Sure enough, I'm using 2.7.5, and the documentation clearly states that 2.5 is necessary. However, the documentation seems to be outdated, because after installing 2.5 and setting my system to use it, I got this error:

Error: Python 2.5 is not supported. Please use version 2.7.

Okay, so back to 2.7.5 and my initial error.

I'm not sure if this is a bug in the dev_appserver.py Python code (I'm guessing not, as it's been out for a month), an issue with my Python installation, or something else about my system that isn't configured according to Google's expectations.

I'd rather not mess with the dev_appserver.py code unless necessary, but I'm happy to poke at it to help figure out what's going wrong. The error is on line 194; here are lines 190-195:

# AF_INET or AF_INET6 socket
# Get the correct address family for our host (allows IPv6 addresses)
host, port = self.bind_addr
try:
info = socket.getaddrinfo(host, port, socket.AF_UNSPEC,
socket.SOCK_STREAM, 0, socket.AI_PASSIVE)

我确定包含方法被调用了两次。第一次 host 始终是 "127.0.0.1" 并且 port0。第二次是崩溃的那个; host 始终是 10(一个 int,而不是一个字符串),port 是一个看似随机的五位数 int。

我已经尝试将 host 硬编码为 "127.0.0.1" 并将 port 硬编码为 80800,但随后出现另一个错误。我感到头晕目眩,我怀疑我不会通过改变我并不真正理解的事情来解决真正的问题。谷歌搜索错误消息没有帮助。

最佳答案

坚持不懈的谷歌搜索最终得到了返回。尽管this question有一个非常不同(并且信息量更大)的错误消息,结果证明解决方案是相同的:确保 /etc/hosts 仅包含一个用于 localhost 的条目。

值得注意的是,我的系统包含以下两行:

127.0.0.1  localhost
::1 localhost

注释掉第二个(并添加注释以记录原因)解决了我的问题:

127.0.0.1  localhost

# Having multiple localhost entries causes App Enginge dev_appserver.py to fail.
# IPv6 not currently needed, and the dev server IS needed, so commenting out.
#::1 localhost

dev_appserver.py 现在启动并正常工作。

关于python - "getaddrinfo() argument 1 must be string or None"在 Linux 上启动 dev_appserver.py 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17588699/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com