在Pycharm的run界面无论运行任何命令都出现 AttributeError: ‘NoneType‘ object has no attribute ‘loader‘

在Pycharm中遇到运行错误,包括NoneTypeobjecthasnoattributeloader和SyntaxError:Missingparenthesesincalltoprint。问题出现在使用requests、lxml和Chaojiying_Client库处理网页请求和验证码识别时。代码尝试从网页抓取验证码图片并进行识别。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

今天不知道是不是哪里误操作了,在Pycharm的run界面无论运行任何命令都出现  AttributeError: 'NoneType' object has no attribute 'loader',如图1

在运行某些代码时还会出现:SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?,如图2、3

图2 代码:

import requests
from lxml import etree
from chaojiying import Chaojiying_Client
header = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.89 Safari/537.36 SLBrowser/7.0.0.5211 SLBChan/25"}
url = 'https://so.gushiwen.org/user/login.aspx?from=http://so.gushiwen.org/user/collect.aspx'
page_text = requests.get(url=url,headers=header).text
tree = etree.HTML(page_text)
code_img_src = 'https://so.gushiwen.org'+tree.xpath('//*[@id="imgCode"]/@src')[0]#解析验证码图片img中src属性值
img_data = requests.get(url=code_img_src,headers=header).content
with open('./爬取验证码.jpg','wb') as fp:
    fp.write(img_data)#将验证码图片保存到了本地
chaojiying = Chaojiying_Client('hc726568076', '123123', '944745')
im = open('//爬取验证码.jpg', 'rb').read()  # 读取保存的图片
print(chaojiying.PostPic(im, 1902))

求各位大佬指点

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值