python-3.x - 如何修复 'AttributeError: cffi library '_constant_time' has no function, constant or global variable named '__spec__'' 在 django 中的错误”
问题描述
我想导入请求库(在 views.py 中)以从其他网站请求一些信息。但是有一个像标题这样的错误
在 ivews.py
from django.http import HttpResponse
from django.http import JsonResponse
from django.core import serializers
import requests
import json
AttributeError:cffi 库“_constant_time”没有名为“ spec ”的函数、常量或全局变量
上述异常是以下异常的直接原因:
Traceback(最近一次调用最后一次):文件“C:/Users/49646/Desktop/auto_order/manage.py”,第 21 行,在
.....如果不是 isinstance(module, ModuleType) 或 getattr(module, ' spec ', None) is None: SystemError: 返回一个带有错误集的结果
解决方案
正如@John-Doe 在评论中指出的那样,升级cffi
到最新版本(现在是 1.14.5)修复了这个完全相同的错误。我已经在 MacOS X 10.14 上使用 Django 3.x 亲自证实了这一点。
推荐阅读
- html - 如何处理我的 Multer 意外错误?
- javascript - 每当数组中有一个项目在我的 React 项目中无法正常工作时显示数组内容
- php - CakePHP:随机查询一个结果,排除两个值
- r - 如何使用随机样本在 R 上创建 Stan 模型
- javascript - 当我将元素添加到购物车时,它添加了两个元素,而不仅仅是一个我该如何更正它?
- github - ArgoCD 私有回购声明式方法
- yarnpkg - 纱线构建有问题:生产
- python - 如果传递了另一个参数,则 Python 函数使参数成为强制性参数
- python - 使用 Tab 键导航到 tkinter OptionMenu
- r - 如何检查函数调用中的列 is.numeric() 是否?