Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use uuid lib with mod_wsgi?

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?

like image 968
AlexisCaffa Avatar asked Nov 09 '15 15:11

AlexisCaffa


2 Answers

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.

like image 86
sergiogarciadev Avatar answered Nov 18 '22 07:11

sergiogarciadev


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.
like image 10
Aaron V Avatar answered Nov 18 '22 06:11

Aaron V