【问题标题】:How to interpret this traceback?如何解释这个回溯?
【发布时间】:2015-10-11 11:56:13
【问题描述】:

我正在设置一台新的开发机器并安装了我的 IDE pycharm。我将python安装到C:\Program (x86)\python27。但是当我启动我的 gae 服务器时,我得到了这个回溯。什么意思?

pydev debugger: process 7576 is connecting

Traceback (most recent call last):
  File "C:\Program Files (x86)\JetBrains\PyCharm 4.5.3\helpers\pydev\pydevd.py", line 2358, in <module>
    globals = debugger.run(setup['file'], None, None, is_module)
  File "C:\Program Files (x86)\JetBrains\PyCharm 4.5.3\helpers\pydev\pydevd.py", line 1778, in run
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "C:\Program Files (x86)\Google\google_appengine\_python_runtime.py", line 83, in <module>
    _run_file(__file__, globals())
  File "C:\Program Files (x86)\Google\google_appengine\_python_runtime.py", line 79, in _run_file
    execfile(_PATHS.script_file(script_name), globals_)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\python\runtime.py", line 175, in <module>
    main()
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\python\runtime.py", line 155, in main
    sandbox.enable_sandbox(config)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\python\sandbox.py", line 189, in enable_sandbox
    from google.appengine.runtime import runtime
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\runtime\runtime.py", line 40, in <module>
    from google.appengine.runtime import cgi
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\runtime\cgi.py", line 32, in <module>
    from email import feedparser
  File "C:\Program Files (x86)\python27\lib\email\feedparser.py", line 27, in <module>
    from email import message
  File "C:\Program Files (x86)\python27\lib\email\message.py", line 16, in <module>
    import email.charset
  File "C:\Program Files (x86)\python27\lib\email\charset.py", line 13, in <module>
    import email.base64mime
  File "C:\Program Files (x86)\python27\lib\email\base64mime.py", line 40, in <module>
    from email.utils import fix_eols
  File "C:\Program Files (x86)\python27\lib\email\utils.py", line 28, in <module>
    import socket
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\python\sandbox.py", line 829, in load_module
    return self.import_stub_module(fullname)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\python\sandbox.py", line 841, in import_stub_module
    __import__(fullname, {}, {})
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\dist27\socket.py", line 73, in <module>
    from _ssl import RAND_add, RAND_egd, RAND_status, SSL_ERROR_ZERO_RETURN, SSL_ERROR_WANT_READ, SSL_ERROR_WANT_WRITE, SSL_ERROR_WANT_X509_LOOKUP, SSL_ERROR_SYSCALL, SSL_ERROR_SSL, SSL_ERROR_WANT_CONNECT, SSL_ERROR_EOF, SSL_ERROR_INVALID_ERROR_CODE
ImportError: cannot import name RAND_egd
pydev debugger: process 2496 is connecting

Traceback (most recent call last):
  File "C:\Program Files (x86)\JetBrains\PyCharm 4.5.3\helpers\pydev\pydevd.py", line 2358, in <module>
    globals = debugger.run(setup['file'], None, None, is_module)
  File "C:\Program Files (x86)\JetBrains\PyCharm 4.5.3\helpers\pydev\pydevd.py", line 1778, in run
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "C:\Program Files (x86)\Google\google_appengine\_python_runtime.py", line 83, in <module>
    _run_file(__file__, globals())
  File "C:\Program Files (x86)\Google\google_appengine\_python_runtime.py", line 79, in _run_file
    execfile(_PATHS.script_file(script_name), globals_)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\python\runtime.py", line 175, in <module>
    main()
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\python\runtime.py", line 155, in main
    sandbox.enable_sandbox(config)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\python\sandbox.py", line 189, in enable_sandbox
    from google.appengine.runtime import runtime
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\runtime\runtime.py", line 40, in <module>
    from google.appengine.runtime import cgi
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\runtime\cgi.py", line 32, in <module>
    from email import feedparser
  File "C:\Program Files (x86)\python27\lib\email\feedparser.py", line 27, in <module>
    from email import message
  File "C:\Program Files (x86)\python27\lib\email\message.py", line 16, in <module>
    import email.charset
  File "C:\Program Files (x86)\python27\lib\email\charset.py", line 13, in <module>
    import email.base64mime
  File "C:\Program Files (x86)\python27\lib\email\base64mime.py", line 40, in <module>
    from email.utils import fix_eols
  File "C:\Program Files (x86)\python27\lib\email\utils.py", line 28, in <module>
    import socket
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\python\sandbox.py", line 829, in load_module
    return self.import_stub_module(fullname)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\python\sandbox.py", line 841, in import_stub_module
    __import__(fullname, {}, {})
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\dist27\socket.py", line 73, in <module>
    from _ssl import RAND_add, RAND_egd, RAND_status, SSL_ERROR_ZERO_RETURN, SSL_ERROR_WANT_READ, SSL_ERROR_WANT_WRITE, SSL_ERROR_WANT_X509_LOOKUP, SSL_ERROR_SYSCALL, SSL_ERROR_SSL, SSL_ERROR_WANT_CONNECT, SSL_ERROR_EOF, SSL_ERROR_INVALID_ERROR_CODE
ImportError: cannot import name RAND_egd

如果我以管理员身份运行 pip install PyOpenSLL 然后我得到

C:\>pip install pyopensll
Collecting pyopensll
  Could not find a version that satisfies the requirement pyopensll (from versio
ns: )
No matching distribution found for pyopensll

C:\>pip install pyOpenSSL
Requirement already satisfied (use --upgrade to upgrade): pyOpenSSL in c:\progra
m files (x86)\python27\lib\site-packages
Requirement already satisfied (use --upgrade to upgrade): six>=1.5.2 in c:\progr
am files (x86)\python27\lib\site-packages (from pyOpenSSL)
Requirement already satisfied (use --upgrade to upgrade): cryptography>=0.7 in c
:\program files (x86)\python27\lib\site-packages (from pyOpenSSL)
Requirement already satisfied (use --upgrade to upgrade): setuptools in c:\progr
am files (x86)\python27\lib\site-packages (from cryptography>=0.7->pyOpenSSL)
Requirement already satisfied (use --upgrade to upgrade): enum34 in c:\program f
iles (x86)\python27\lib\site-packages (from cryptography>=0.7->pyOpenSSL)
Requirement already satisfied (use --upgrade to upgrade): pyasn1 in c:\program f
iles (x86)\python27\lib\site-packages (from cryptography>=0.7->pyOpenSSL)
Requirement already satisfied (use --upgrade to upgrade): idna in c:\program fil
es (x86)\python27\lib\site-packages (from cryptography>=0.7->pyOpenSSL)
Requirement already satisfied (use --upgrade to upgrade): ipaddress in c:\progra
m files (x86)\python27\lib\site-packages (from cryptography>=0.7->pyOpenSSL)
Requirement already satisfied (use --upgrade to upgrade): cffi>=0.8 in c:\progra
m files (x86)\python27\lib\site-packages (from cryptography>=0.7->pyOpenSSL)
Requirement already satisfied (use --upgrade to upgrade): pycparser in c:\progra
m files (x86)\python27\lib\site-packages (from cffi>=0.8->cryptography>=0.7->pyO
penSSL)

C:\>

【问题讨论】:

  • 您不能导入RAND_egd。见ImportError: cannot import name RAND_egd(最后一行)。
  • 抱怨找不到应该存在的 RAND_egd
  • 我重新安装了 pip 仍然得到同样的错误。谷歌中没有找到cannot import name RAND_egd

标签: python google-app-engine windows-8.1 pycharm


【解决方案1】:

新:

您似乎使用的是 LibreSSl 而不是 OpenSSL。见Python: Issue 21356

通过在 python-shell 中运行它来检查您是否正在使用 LibreSSL:

from ssl import OPENSSL_VERSION; print OPENSSL_VERSION

旧:

File "C:\Program Files (x86)\Google\google_appengine\google\appengine\dist27\socket.py", line 73, in <module>
    from _ssl import RAND_add, RAND_egd, RAND_status, SSL_ERROR_ZERO_RETURN, SSL_ERROR_WANT_READ, SSL_ERROR_WANT_WRITE, SSL_ERROR_WANT_X509_LOOKUP, SSL_ERROR_SYSCALL, SSL_ERROR_SSL, SSL_ERROR_WANT_CONNECT, SSL_ERROR_EOF, SSL_ERROR_INVALID_ERROR_CODE
ImportError: cannot import name RAND_egd

是你必须知道的。在相当简单的写作中,这意味着: “Google 的应用引擎无法在模块 _ssl 中找到名为 RAND_egd 的名称”

尝试更新所有包。

从控制台尝试from _ssl Import RAND_egd,然后将结果放在这里。

【讨论】:

  • 如果我从控制台执行此操作,那么我会得到一个ImportError: cannot import name RAND_egd
  • 这是全新安装。我有一台开发环境完美运行的 ubuntu 机器。现在我正在尝试在 MS-Windows 8.1 机器上设置开发环境,我已经做到了这一点。如果重要的话,我把我的python安装放在C:\Program (x86)\python27而不是C:\python
  • 您知道可能是什么问题吗?我不明白为什么它不起作用。我的另一个安装运行得很好,那就是 Ubuntu。
  • 对此,请参阅:Python 2.7 - ssl.py,第 108-112 行。那里也有描述:>> LibreSSL 不提供 RAND_egd
  • 您可能需要以管理员权限运行该命令。
【解决方案2】:

目前,公开的问题列表中没有提到 RAND_egd 的任何错误。我建议 filing a bug 解决这个问题,包括堆栈跟踪并提到您在 Windows 8.1 上看到了这个问题。包含指向此 stackoverflow 问题的链接。

这仍然会给您留下一个直接的问题,因此请考虑尝试此实验:编辑 google_appengine\google\appengine\dist27\socket.py 并删除对 RAND_egd 的引用(将原始行的副本注释掉,或制作 socket.py 的副本,以便您可以轻松还原更改)。然后看看会发生什么。你可能会走运。请回来报告。

【讨论】:

  • 感谢您的回答。我要提交错误报告。如果我注释掉 RAND_egd 引用,则会收到此错误 ImportError: No module named wtforms 但 wtforms 实际上存在。它适用于 Ubuntu。
  • 在 SDK 附近工作时,像这样的东西曾经让我发疯。一切都会好起来的,然后操作系统(通常)或 Python(很少)版本会在一个平台上翻车,直到我们可以修复到下一个版本。对不起,你走错了。
  • 我现在将其归档为问题 12176。感谢您的帮助。 code.google.com/p/googleappengine/issues/…
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-04-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-02-12
  • 2020-05-09
  • 2013-03-10
相关资源
最近更新 更多