How to fix ‘AttributeError: cffi library '_constant_time' has no function, constant or global variable named '__spec__'’ error in django”

Viewed 852

I want to import requests lib (in views.py)to request some information from the other website. but there is a error like title

in ivews.py

from django.http import HttpResponse

from django.http import JsonResponse

from django.core import serializers

import requests

import json

AttributeError: cffi library '_constant_time' has no function, constant or global variable named 'spec'

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "C:/Users/49646/Desktop/auto_order/manage.py", line 21, in
..... if not isinstance(module, ModuleType) or getattr(module, 'spec', None) is None: SystemError: returned a result with an error set

1 Answers

As @John-Doe notes in the comments, upgrading cffi to latest version (now 1.14.5) fixes this exact same error. I've personally confirmed this with Django 3.x on MacOS X 10.14.

Related