![](https://img-blog.csdnimg.cn/20201014180756757.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
BUG
python小明
bug虐我千百遍,我待bug如初恋!
展开
-
UnorderedObjectListWarning: Pagination may yield inconsistent results with an unordered object_list
错误: UnorderedObjectListWarning: Pagination may yield inconsistent results with an unordered object_list这个错误是在使用Django的DRF框架编写接口时,配置了分页之后出现的分页警告,仅是警告而已,不影响正常运行,但是对于强迫症的我总想解决掉。解决方案一: 在模型处配置排序class XXXXX(models.Model): # XXXXX为自定义 name = models.CharFiel原创 2021-12-28 17:17:51 · 3943 阅读 · 0 评论 -
python报错:Excel xlsx file; not supported
错误: Excel xlsx file; not supported原因: xlrd包在版本1.2.0之后就不支持xlsx格式了,支持xls格式解决方案一:回退版本:卸载新版本 pip uninstall xlrd安装老版本:pip install xlrd=1.2.0 (或者更早版本)解决方案二:将xlrd用到的excel版本格式修改为xls,为防止出错导致数据丢失,建议另存为xls格式。...原创 2021-11-09 14:06:26 · 10860 阅读 · 0 评论 -
使用pandas读取excel表时报错:Missing optional dependency ‘fsspec‘. Use pip or conda to install fsspec.
错误: Missing optional dependency ‘fsspec’. Use pip or conda to install fsspec.解析: 缺失必要的第三方包:fsspec解决方案: 在当前环境下下载该包:pip install fsspec原创 2021-11-09 13:50:40 · 15245 阅读 · 0 评论 -
AttributeError: module ‘calendar‘ has no attribute ‘monthlen‘
错误内容: AttributeError: module ‘calendar’ has no attribute ‘monthlen’错误原因: python的版本问题,python3.7以下的版本calendar模块没有monthlen方法,我用的是3.6.5,所以会报该错误。解决办法1: 升级python,升级办法自行寻找。解决办法2: 使用monthrange来代替monthlen,monthlen方法返回当月的天数:3.7环境下测试:monthrange方法返回一个元组:该元组第一个数表原创 2021-09-29 15:54:16 · 1333 阅读 · 0 评论 -
Related Field got invalid lookup: icontains
错误内容: Related Field got invalid lookup: icontains错误原因:这个错误一般是由于你在views.py文件里的search_fields使用了外键,而没有指定具体的字段。比如:我的模型是Feedback,外键是supervise,在这里配置搜索字段时写成:search_fields = [“supervise”, “supervise”] 就会报这个错误解决方法: 应该指明具体字段,如下图:(注意中间是两个下划线)...原创 2021-09-23 16:48:28 · 1503 阅读 · 0 评论 -
ERROR: Could not install packages due to an OSError: [Errno 13] Permission denied
报错内容: ImportError: C extension: DLL load failed: 拒绝访问。 not built. If you want to import pandas from the source directory, you may need to run ‘python setup.py build_ext --inplace --force’ to build the C extensions first.报错原因: 有可能是自己手误删除了环境中的pandas的安装依赖包导致原创 2021-09-23 11:36:33 · 11151 阅读 · 6 评论 -
django models报错Manager isn‘t accessible via UserInfo instances
错误内容: Manager isn’t accessible via UserInfo instances错误原因: 是因为调用模型对象时使用了变量名,而不是对象名(模型类),例如:user = UserInfo()user_li = user.objects.filter(uname=username),这种调用情况就会报此错误解决方法: 使用对象名调用objects方法user = UserInfo()user_li = UserInfo.objects.filter(uname=usern原创 2021-09-18 18:35:56 · 779 阅读 · 0 评论 -
django报错:Cannot assign \“6\“: \“Feedback.supervise\“ must be a \“Supervise\“ instance
报错内容:Cannot assign “6”: “Feedback.supervise” must be a “Supervise” instance报错原因及说明: 因为Feedback模型的supervise字段为ForeignKey类型,所以在实例化新建的是要一个Supervise实例化对象才可以,不能传字符串类型。纠正方案:supervise = models.Supervise.objects.get(id=response.data.get('id'))# 新建时直接将实例化对象supe原创 2021-09-15 18:04:02 · 171 阅读 · 0 评论 -
ImportError: failed to find libmagic. Check your installation
错误详情:ImportError: failed to find libmagic. Check your installation解决方法1:使用命令pip uninstall python-magicpip install python-magic-bin==0.4.14解决方法2:卸载python-magic然后在官网可以下载64位对应安装包。接着使用命令pip install python_magic_bin-0.4.14-py2.py3-none-win_amd64.whl原创 2021-08-12 10:12:09 · 2341 阅读 · 0 评论 -
导入from django.utils.six.moves.urllib import parse as urlparse报错
from django.utils.six.moves.urllib import parse as urlparse改成from urllib.parse import urlparse原创 2021-08-02 11:30:43 · 713 阅读 · 0 评论 -
python中导入utils.six.moves.urllib报错
1、Django3.0.3移除了six。2.six可以单独安装:pip install six。另外,urllib 好像也独立出来了,引用时不需有前缀。from django.utils.six.moves.urllib.request import urlopenfrom django.utils.six.moves.urllib.parse import urljoin改为:from six.moves.urllib.request import urlopenfrom six.moves.原创 2021-08-02 11:26:56 · 1947 阅读 · 0 评论 -
No matching distribution found for yaml
错误信息:直接pip install yaml了或者直接conda install yaml,导致报错:Could not find a version that satisfies the requirement yaml (from versions: )No matching distribution found for yaml错误原因:python3里面yaml的名字叫做pyyaml。更正措施:pip install pyyaml或者conda install pyyaml,才行!原创 2021-08-02 11:21:29 · 1999 阅读 · 0 评论 -
django中数据库迁移报错:TypeError: argument of type ‘WindowsPath‘ is not iterable
错误信息:TypeError: argument of type ‘WindowsPath’ is not iterable更正措施:在settings.py中修改DATABASES:修改以下代码:'NAME': BASE_DIR / 'db.sqlite3',修改为:'NAME': str(os.path.join(BASE_DIR, "db.sqlite3")),原创 2021-07-29 14:03:50 · 522 阅读 · 0 评论 -
python-pip升级报错- AttributeError: ‘NoneType‘ object has no attribute ‘bytes‘
正常更新pip命令:python3 -m pip install --upgrade pip报错内容:AttributeError: ‘NoneType’ object has no attribute ‘bytes’解决办法:更换命令:easy_install -U pip原创 2021-07-27 15:30:33 · 165 阅读 · 0 评论