How to use uuid lib with mod_wsgi?

空扰寡人 提交于 2019-12-13 15:25:39

问题


This is the traceback:

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

Not sure where the problem lies... has the uuid.py lib a bug?


回答1:


uuid is bundled with python since version 2.5, see docs, you should not install it in your virtual environment.

There is no need to install it.




回答2:


After wrestling with this today, what solved it for me was actually Daniel Roseman's comment.

If you're getting this error in Python 3, it's because you've inadvertently installed the uuid Python 2 backport, which is masking the standard library uuid, which is what you presumably want to import.

So:

  1. Run pip uninstall uuid to uninstall the extraneous backport.
  2. Make sure none of your packages list uuid as a requirement for python versions greater than 2.5.


来源:https://stackoverflow.com/questions/33612977/how-to-use-uuid-lib-with-mod-wsgi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!