Cygwin 64位上的UUID python导入失败

Tan*_*aho 7 python uuid cygwin

我在虚拟环境包装器中运行python,我尝试导入UUID.以下是我收到的内容:

python -v
>>> import uuid


# /home/tanzaho/.virtualenvs/django_wordiz/lib/python2.7/site-packages/uuid.pyc matches /home/tanzaho/.virtualenvs/django_wordiz/lib/python2.7/site-packages/uuid.py
import uuid # precompiled from /home/tanzaho/.virtualenvs/django_wordiz/lib/python2.7/site-packages/uuid.pyc
import ctypes # directory /usr/lib/python2.7/ctypes
# /usr/lib/python2.7/ctypes/__init__.pyc matches /usr/lib/python2.7/ctypes/__init__.py
import ctypes # precompiled from /usr/lib/python2.7/ctypes/__init__.pyc
dlopen("/home/tanzaho/.virtualenvs/django_wordiz/lib/python2.7/lib-dynload/_ctypes.dll", 2);
import _ctypes # dynamically loaded from /home/tanzaho/.virtualenvs/django_wordiz/lib/python2.7/lib-dynload/_ctypes.dll
# /usr/lib/python2.7/struct.pyc matches /usr/lib/python2.7/struct.py
import struct # precompiled from /usr/lib/python2.7/struct.pyc
dlopen("/home/tanzaho/.virtualenvs/django_wordiz/lib/python2.7/lib-dynload/_struct.dll", 2);
import _struct # dynamically loaded from /home/tanzaho/.virtualenvs/django_wordiz/lib/python2.7/lib-dynload/_struct.dll
# /usr/lib/python2.7/ctypes/_endian.pyc matches /usr/lib/python2.7/ctypes/_endian.py
import ctypes._endian # precompiled from /usr/lib/python2.7/ctypes/_endian.pyc
# /usr/lib/python2.7/ctypes/util.pyc matches /usr/lib/python2.7/ctypes/util.py
import ctypes.util # precompiled from /usr/lib/python2.7/ctypes/util.pyc
Run Code Online (Sandbox Code Playgroud)

之后,python停止,没有任何其他警告.我试图从Cygwin重新安装该库,但这没有帮助.

有没有办法解决这个问题?

我应该指定我在Windows7 64位下使用python 2.7.

编辑 以下链接帮助我找到了一个可能的错误源:Bug python 18784.但我查看了补丁中指定的代码,似乎python甚至没有达到这一点.

解决 方案由于我的声誉太低,我无法"输入解决方案",因此我将其作为编辑发布在此处.我通过以下补丁找到了解决方案:http: //bugs.python.org/file20685/issue11063.patch

小智 6

我在64位Cygwin上有相同的症状.安装"libuuid-devel"和"binutils"Cygwin软件包为我解决了导入崩溃问题.

有关解决方案的更多讨论,请访问:https://github.com/kennethreitz/requests/issues/1547.


Aro*_*dia 0

正如 Yaakov 指出的那样,您遇到的错误已被报告为CPython Issue 18784,并已于 2013 年 9 月 13 日在 Python 2.7、3.3 和开发分支 (3.4) 的维护分支中得到修复。

如果您需要修补现有的 Python 系统,可以使用Evgeny Sologubov 提供的以下简单补丁来完成,该补丁可以使 uuid 模块短路,使其无法在找到 uuid 例程后尝试加载更多库:

diff -r 4a318a45c4c3 Lib/uuid.py
--- a/Lib/uuid.py   Mon Aug 19 13:07:18 2013 -0400
+++ b/Lib/uuid.py   Mon Aug 19 21:41:08 2013 +0400
@@ -429,6 +429,8 @@
             _uuid_generate_random = lib.uuid_generate_random
         if hasattr(lib, 'uuid_generate_time'):
             _uuid_generate_time = lib.uuid_generate_time
+            if _uuid_generate_random is not None:
+                break  # found everything we were looking for

     # The uuid_generate_* functions are broken on MacOS X 10.5, as noted
     # in issue #8621 the function generates the same sequence of values
Run Code Online (Sandbox Code Playgroud)

ctypes 还存在一些更深层次的问题需要解决,但这应该可以解决人们在 Cygwin64 上安装 Python 包时遇到的许多主要问题。