如何在mod_wsgi中使用uuid库?

Ale*_*ffa 2 python django mod-wsgi

这是回溯:

mod_wsgi: Target WSGI script '/[..]/project/wsgi.py' cannot be loaded as Python module.
mod_wsgi: Exception occurred processing WSGI script '/[..]/project/wsgi.py'.

Traceback (most recent call last):
   File "/home/ubuntu/api/api/wsgi.py", line 11, in <module>
     import uuid as uuid
   File "/home/ubuntu/.virtualenvs/api/lib/python3.4/site-packages/uuid.py", line 138
     if not 0 <= time_low < 1<<32L:
                                 ^
 SyntaxError: invalid syntax
Run Code Online (Sandbox Code Playgroud)

不知道问题出在哪里... uuid.py lib有错误吗?

Law*_*ker 5

从2.5版开始,uuid与python捆绑在一起,请参阅docs,不应将其安装在虚拟环境中。

无需安装。


Aar*_*n V 5

经过今天的努力,为我解决的实际上是丹尼尔·罗斯曼的评论

如果您在Python 3中遇到此错误,那是因为您无意中安装了uuidPython 2反向端口,该端口掩盖了标准库uuid(可能是您想导入的标准库)

所以:

  1. 运行pip uninstall uuid以卸载无关的反向端口。
  2. 确保没有任何软件包列表uuid是大于2.5的python版本的要求。