Forums

AttributeError: 'UUID' object has no attribute 'replace'

I'm trying to deploy a flask api, I've experienced this issue before.

File "/usr/lib/python3.8/uuid.py", line 166, in __init__
hex = hex.replace('urn:', '').replace('uuid:', '')

I resolved it by modifying uuid.py to hex = str(hex).replace('urn:', '').replace('uuid:', '') but in this case I don't have permission to modify this file. I've also tried using a virtual environment and installing the uuid module but it didn't make a difference. Is there a work around?

The uuid module is a built-in Python module, and you shouldn't change it. What code is trying to call a non-existent function on that built-in module? If it's your own code, then you should change it so that it only calls functions that exist. If it's a third-party module, then perhaps you're using a version that is not compatible with Python 3?