CodeBug
python django Linux shell 遇到的bug
程序员老五
不积跬步无以至千里
展开
-
JSON读取文件报错 raise JSONDecodeError(“Extra data“, s, end) json.decoder.JSONDecodeError: Extra data等类似错
原因可能是文件过大导致的,可以逐行读取,并把。使用 Python 读取文件并用。原创 2023-05-05 07:33:50 · 1161 阅读 · 0 评论 -
警告:MySQL-server-5.6.27-1.linux_glibc2.5.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY 错误
警告:MySQL-server-5.6.27-1.linux_glibc2.5.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY错误:依赖检测失败: /usr/bin/perl 被 MySQL-server-5.6.27-1.linux_glibc2.5.x86_64 需要原创 2022-03-15 20:06:25 · 975 阅读 · 0 评论 -
object supporting the buffer API required
Django项目中初始化数据库执行 python manage.py makemigratoins 时报错:object supporting the buffer API required,则将 setting.py 中MySQL的密码改为字符串形式即可DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'meeting_room', 'HOST': '原创 2022-02-26 13:37:07 · 2145 阅读 · 0 评论 -
Your password does not satisfy the current policy requirements
安装MySQL之后进入MySQL设置简单的密码比如 "123456" 这样的会提示密码设置的太简单了,正常需要大小写数字加特殊符号的,如果要设置简单的可以做以下两个设置即可:mysql> set global validate_password_policy=0;Query OK, 0 rows affected (0.00 sec) mysql> set global validate_password_length=6;Query OK, 0 rows affected (0.00原创 2021-11-23 14:23:25 · 472 阅读 · 0 评论 -
idea导入本地的jar包 Mac
按提示操作即可:File → Project StructureLibraries → + → Java选择自己本地的jar包文件夹lib:然后点击Apply → OK 即可。原创 2021-11-07 16:14:49 · 323 阅读 · 0 评论 -
Failed to start LSB: Bring up/down networking
使用xshell等工具连接CentOS7时发现连不上了,进入CentOS使用 ip a 查看ip时发现ipv4的地址没有了,之前用的好好的。根据提示使用 systemctl status network.service 查看原因为:Failed to start LSB: Bring up/down networking处理这个问题的方法:1. 关闭并禁用网络管理器systemctl stop NetworkManagersystemctl disable NetworkManager然后原创 2021-09-28 09:19:46 · 206 阅读 · 0 评论 -
安装MySQL报错 /usr/bin/perl 被 MySQL-server-5.6.27-1.linux_glibc2.5.x86_64 需要
安装MySQL时报错,信息为:说明需要Perl依赖,下载该包:yum install -y perl-Module-Install.noarch然后再安装MySQL即可。原创 2021-08-22 15:06:57 · 859 阅读 · 0 评论 -
AttributeError: ‘NoneType‘ object has no attribute ‘find_all‘
极客时间Python核心技术与实战案例:豆瓣今日推荐电影爬虫老师提供的原代码如下:import requestsfrom bs4 import BeautifulSoupimport timedef main(): url = "https://movie.douban.com/cinema/later/beijing/" init_page = requests.get(url).content init_soup = BeautifulSoup(init原创 2021-08-06 10:55:58 · 2461 阅读 · 0 评论 -
bs4.FeatureNotFound: Couldn‘t find a tree builder with the features you requested: lxml. Do you need
代码如图所示:报错信息为:原因虽然代码中没有引入有关lxml的包,但需要有这个包:pip3 install lxml再执行就没问题了。原创 2021-08-06 10:08:31 · 130 阅读 · 0 评论 -
ConnectionRefusedError: [WinError 10061] 由于目标计算机积极拒绝,无法连接。
两台机器或一台机器上进行多进程交换数据时报连接拒绝,原因是计算机网络连接共享没有设置。按以下操作步骤进行操作,然后再尝试连接即可。如果还不行的话,就稍等再尝试,如果还不行,就检查防火墙是否关闭。...原创 2021-04-21 17:14:24 · 2737 阅读 · 0 评论 -
TypeError: not all arguments converted during string formatting
字符串格式化输出时,其中一种方法是这样的:for value in ['A', 'B', 'C']: print('输出: %s' % value)我这打印子进程运行状态时print()了列表中的几个字符串,但报错如下:TypeError: not all arguments converted during string formatting翻译为:不是所有的参数在字符串格式化期间转换,我屮艸芔茻,出错位置看了下,原来是%打错了,打成了$,开始不知道啥原因,这错误第一次见,把这个信息发原创 2021-03-31 09:53:29 · 29740 阅读 · 8 评论 -
xlrd.biffh.XLRDError: Excel xlsx file; not supported
使用python的xlrd读取Excel文件时报错:xlrd.biffh.XLRDError: Excel xlsx file; not supported报错原因是xlrd版本的问题,现在直接pip install xlrd下载的是2.0.1版本的,将其卸载下载1.2.0的即可。解决方法:pip3 install xlrd==1.2.0说明:如果你的电脑同时安装了py2和py3,直接使用pip install xlrd默认该包是指向py2的,如果你使用的是py3,则使用 pip3 ins原创 2021-01-14 10:36:55 · 37197 阅读 · 19 评论 -
AttributeError: ‘RelatedManager‘ object has no attribute ‘pk‘
使用django-rest-framework开发使用外键关系属性输出时报错信息如下:。。。packages\rest_framework\relations.py", line 271, in to_representation return value.pkAttributeError: 'RelatedManager' object has no attribute 'pk'解释:当关系属性关系是多对一的时候,需要在关系属性输出时不但要设置只读,还有添加many=Truexxx原创 2020-12-31 09:59:09 · 1817 阅读 · 0 评论 -
AttributeError: type object ‘BookAPIView‘ has no attribute ‘get_extra_actions‘
django-rest-framework开发时报错 如下:。。。。。。File "/Users/user/Desktop/PythonProject/django_restful_drf/venv/lib/python3.9/site-packages/rest_framework/routers.py", line 236, in get_urls routes = self.get_routes(viewset) File "/Users/user/Desktop/PythonProj原创 2020-12-30 22:37:57 · 2919 阅读 · 0 评论 -
File “manage.py“, line 17 ) from exc ^ SyntaxError: invalid syntax
新创建的Django项目,进入后直接运行python manage.py runserver时报错如下:user@UserdeMacBook-Pro djangoProject % python manage.py runserver File "manage.py", line 17 ) from exc ^SyntaxError: invalid syntax感觉有点莫名其妙,后来发现python版本指定的有问题,应该指定python3版本python3 m原创 2020-12-22 22:37:49 · 3759 阅读 · 0 评论 -
Cannot use the @action decorator on the following methods, as they are existing routes: destroy
Django使用drf 视图集开发接口进行测试时,报错如下:(venv-task) F:\python\python-drf\drf_project4>python manage.py runserverWatching for file changes with StatReloaderPerforming system checks...Exception in thread django-main-thread:Traceback (most recent call last):原创 2020-12-15 14:26:20 · 751 阅读 · 4 评论 -
RuntimeError: ‘cryptography‘ package is required for sha256_password or caching_sha2_password auth m
执行 python manage.py runserver 时报错:。。。。。。 File "/Users/jason93/Desktop/PythonProject/django_drf/venv-djdrf/lib/python3.9/site-packages/pymysql/_auth.py", line 204, in sha2_rsa_encrypt raise RuntimeError("'cryptography' package is required for sha256_原创 2020-12-13 11:38:00 · 5032 阅读 · 5 评论 -
1045, “Access denied for user ‘jason93‘@‘localhost‘ (using password: NO)“
Django项目 python manage.py runserver 或 python manage.py makemigrations时报错信息如下:django.db.utils.OperationalError: (1045, "Access denied for user 'jason93'@'localhost' (using password: NO)")这个报错信息很明显,是mysql设置类密码,但配置里没有写进入settings.py找到 DATABASES发现没写全配置。尴尬原创 2020-12-10 21:54:22 · 189 阅读 · 0 评论 -
Forbidden (CSRF cookie not set.): /books/ [09/Dec/2020 13:42:54] “POST /books/ HTTP/1.1“
使用postman或前端页面发送POST请求时报错如下:Forbidden (CSRF cookie not set.): /books/[09/Dec/2020 13:42:54] "POST /books/ HTTP/1.1" 403 2864这个错误很明显,是csrf禁止访问,去项目settings.py的MIDDLEWARE中找到csrf一行,注释掉:MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware',原创 2020-12-09 21:46:27 · 464 阅读 · 0 评论 -
ImproperlyConfigured: mysqlclient 1.4.0 or newer is required; you have 0.10.1.
执行 python manage.py makemigrations 时报错。报错信息如下:(venv-task) F:\python\python-drf\dj_restful_project>python manage.py makemigrationsTraceback (most recent call last): File "F:\python\python-drf\dj_restful_project\manage.py", line 22, in <module>原创 2020-12-09 14:42:45 · 578 阅读 · 0 评论 -
python manage.py makemigrations报错 TypeError: object supporting the buffer API required
报错信息如下:(venv-small_box) jason93@Jason93deMacBook-Pro small_box % python manage.py makemigrationsTraceback (most recent call last): File "/Users/jason93/Desktop/PythonProject/djangoProject/small_box/manage.py", line 22, in <module> main() Fi原创 2020-12-06 18:20:34 · 544 阅读 · 0 评论 -
AttributeError: ‘str‘ object has no attribute ‘decode‘
python启动项目AttributeError: ‘str’ object has no attribute 'decode’报错报错信息如下:(venv) F:\python\test_project\Coconut>python manage.py runserverWatching for file changes with StatReloaderPerforming system checks...System check identified no issues (0 sil原创 2020-11-23 15:59:56 · 2346 阅读 · 1 评论 -
django-admin.py startproject xxx 创建项目报错ImportError: No module named django.core
这里写自定义目录标题欢迎使用Markdown编辑器新的改变功能快捷键合理的创建标题,有助于目录的生成如何改变文本的样式插入链接与图片如何插入一段漂亮的代码片生成一个适合你的列表创建一个表格设定内容居中、居左、居右SmartyPants创建一个自定义列表如何创建一个注脚注释也是必不可少的KaTeX数学公式新的甘特图功能,丰富你的文章UML 图表FLowchart流程图导出与导入导出导入欢迎使用Markdown编辑器你好! 这是你第一次使用 Markdown编辑器 所展示的欢迎页。如果你想学习如何使用Mar原创 2020-11-23 14:53:25 · 419 阅读 · 0 评论