随笔分类 -  Python Error

摘要:学习自:完美解决:执行pip时Unable to create process using ‘“‘错误(详细流程)-CSDN博客 1、背景 1)在一台新电脑上安装了python3.6; 2)将python3.6和python3.6的Scripts目录都加入到了环境变量中; 3)cmd命令行中输入py 阅读全文
posted @ 2023-12-06 15:11 ShineLe 阅读(1357) 评论(0) 推荐(0) 编辑
摘要:问题 在用df.plot.bar()绘制柱状图时,预想中分开的多列却绘制到了一列中,导致绘制结果出错 预期 错误绘制 原始数据 我的数据是由date和energy两列构成的,需要绘制时间与数值柱状图。 原始代码 df.plot.bar(x=0,y=1) 从原始代码中可以看出我是想用第0列date做横 阅读全文
posted @ 2023-03-27 17:39 ShineLe 阅读(506) 评论(0) 推荐(0) 编辑
摘要:0、问题 在用Tkinter进行编程时,需要在一个Frame下显示多个图片,但是不管怎么设置都是只显示最后一张,就像这样: 代码 for i in range(3): ... image=ImageTk.PhotoImage(f'img{i}.png')#分别打开img1,img2,img3并显示 阅读全文
posted @ 2022-01-07 21:42 ShineLe 阅读(1510) 评论(1) 推荐(0) 编辑
摘要:原因 在Python函数中调用了某个和全局变量同名的局部变量,导致编译器不知道此时使用的是全局变量还是局部变量 a = 3 def func(): a+=3 func() UnboundLocalError:.... 解决方法 在函数中,用global声明该变量为全局变量: a = 3 def fu 阅读全文
posted @ 2022-01-07 14:18 ShineLe 阅读(150) 评论(0) 推荐(0) 编辑
摘要:是random模块下的sample函数,而不是np.random。 阅读全文
posted @ 2021-11-17 15:41 ShineLe 阅读(1065) 评论(0) 推荐(0) 编辑
摘要:pyinstaller打包exe文件出现命令窗口一闪而过 原因:exe运行过程中出错了,解决这些错误就可以了 解决方法: 通过 cd path >> xxx.exe 在命令行中运行exe文件,就可以显示出运行错误了。 阅读全文
posted @ 2021-04-15 20:37 ShineLe 阅读(813) 评论(0) 推荐(0) 编辑
摘要:1、DLL load failed 说明没有找到某个DLL 解决方法: 在 D:\Anaconda\Anaconda3\Library\bin 下找到缺失的DLL,复制到dist下 2、No module named xxx https://blog.csdn.net/ouening/article 阅读全文
posted @ 2021-04-15 20:30 ShineLe 阅读(1272) 评论(0) 推荐(0) 编辑
摘要:1、输出为CSV文件时,Permission denied 原因可能是: (1)构建DataFrame时没有写index参数 (2)用Dict构建最开始的数据时,value没有写成List的形式,例如 #错误 data={ 'name':'Lee', 'age':13 } #正确 data={ 'n 阅读全文
posted @ 2021-04-11 12:37 ShineLe 阅读(575) 评论(0) 推荐(0) 编辑
摘要:'gbk' codec can't decode byte 0x80 in position xx open文件时,添加参数'encoding='utf-8' 'utf-8' codec can't decode byte 0x80 in position xx open文件时,添加参数'encod 阅读全文
posted @ 2021-04-08 23:57 ShineLe 阅读(132) 评论(0) 推荐(0) 编辑
摘要:1、KeyError: 'Spider not found: BDS' 原因:settings.py中缺少了几项与spider名字配置相关的项: BOT_NAME = 'BDS' SPIDER_MODULES = ['County.spiders'] NEWSPIDER_MODULE = 'Coun 阅读全文
posted @ 2021-04-08 16:49 ShineLe 阅读(287) 评论(0) 推荐(0) 编辑
摘要:1、only size-1 arrays can be converted to Python scalars 问题来源:需要把一个float数组A转为int,于是直接在代码中写了 B=int(A),从而报错。 原因:int函数只能对单个数字进行,而不能对一个数组进行 解决方法:用map函数,对数组 阅读全文
posted @ 2020-12-14 15:04 ShineLe 阅读(950) 评论(0) 推荐(0) 编辑
摘要:原因:pip安装库时不需要进入Python环境,在Python环境下安装就会出现SyntaxError 解决方法:输入exit(),退出Python环境,然后就可以pip安装了 阅读全文
posted @ 2020-10-22 20:28 ShineLe 阅读(498) 评论(0) 推荐(0) 编辑
摘要:背景:安装了最新版本的Anaconda3.9后,在Pycharm中设置Python Interpreter为这个最新版本Anaconda文件下的python.exe后,控制台无法启动并报错TypeError: an integer is required (got type bytes) 原因:电脑 阅读全文
posted @ 2020-10-15 20:46 ShineLe 阅读(7285) 评论(0) 推荐(0) 编辑
摘要:使用PIL时,创建某个字体Font对象时出错: font=ImageFont.truetype('Arial.ttf',36) 可能原因有两个: 1、PIL无法定位到字体文件的位置。 可以通过提供绝对路径解决,比如 font=ImageFont.truetype('C:\Windows\Fonts\ 阅读全文
posted @ 2020-10-14 13:06 ShineLe 阅读(2265) 评论(0) 推荐(0) 编辑
摘要:with open('Test.bmp', 'rb') as f: s = f.read(30) #利用struct提取信息 struct.unpack('<ccIIIIIHH',s) #报错 #struct.error: unpack requires a buffer of 26 bytes 原 阅读全文
posted @ 2020-10-09 20:06 ShineLe 阅读(9631) 评论(0) 推荐(2) 编辑
摘要:原因: 在将Queue注册到网上的时候,callable参数使用了lambda匿名函数,而Windows下绑定调用接口不能用lambda QueueManager.register('get_task_queue',callable=lambda:task_queue) QueueManager.r 阅读全文
posted @ 2020-10-07 13:01 ShineLe 阅读(629) 评论(0) 推荐(0) 编辑
摘要:L=[] L[0]=2 L[1]=3 报错:IndexError: list assignment index out of range,列表超过限制 一种情况是:list[index]的index超出范围 另一种情况是:list是一个空的,没有一个元素,进行list[0]就会出现错误! 本例是第二 阅读全文
posted @ 2020-10-06 16:38 ShineLe 阅读(12869) 评论(0) 推荐(0) 编辑
摘要:当在同一行为两个变量赋值时,要用分号;而非逗号,隔开 阅读全文
posted @ 2020-10-06 16:29 ShineLe 阅读(360) 评论(0) 推荐(0) 编辑
摘要:创建字典对象时: D1=dict('name'='Bob','age'=20,'score'=90) SyntaxError: keyword can't be an expression 解决方法: 去掉变量的单引号'' D1=dict(name='Bob',age=20,score=90) 补充 阅读全文
posted @ 2020-10-05 13:54 ShineLe 阅读(4176) 评论(0) 推荐(0) 编辑
摘要:1、SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape 或者 OSError: [Errno 22] Invalid ar 阅读全文
posted @ 2020-09-22 16:22 ShineLe 阅读(292) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示