问题
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:
- Run
pip uninstall uuid
to uninstall the extraneous backport. - 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