报错处理
石山下
这个作者很懒,什么都没留下…
展开
-
报错处理:module ImportError: No module named
Pycharm中import requests时,显示module ImportError: No module named。通过pip list查看显示已安装。确定下载了requests但 pycharm 在 import 的时候还是报错,那么可能是 pycharm 配置的python解析器。解决方案:1.pycharm->File->Settings->Project Int...原创 2018-06-13 21:27:55 · 3845 阅读 · 1 评论 -
爬虫报错:‘NoneType’ object is not iterable
根据《python网络爬虫从入门到实践》学习安居客租房数据爬取时,运行代码:tags = [i.text for i in tag_list]出现以下报错:‘NoneType’ object is not iterable打印tag_list发现,其中有多个元素为None,导致遍历的时候将None赋给多个i时。将代码修改为,报错即可解决:tag_list = house.f...原创 2018-09-02 11:20:50 · 8337 阅读 · 1 评论 -
爬虫报错:Do you need to install a parser library?
利用爬虫爬取安居客租房数据时遇到这个问题,经查阅解决方式如下:将soup = BeautifulSoup(r.text, 'lxml')修改成如下形式即可:soup = BeautifulSoup(r.text, 'html.parser')...原创 2018-09-02 11:13:24 · 22343 阅读 · 5 评论 -
报错处理:Python操作Mysql数据库插入中文错误
学习《python网络爬虫从入门到实践》中遇到以下错误:Incorrect string value: '\xE7\xA8\x8B\xE5\xBA\x8F...' for column 'course' at row 1出现这个错误的原因是,数据库的编码格式为latin1 而我要将utf8的中文插入到数据库中。一开始修改 修改数据库的编码alter table score de...转载 2018-09-04 20:34:15 · 2850 阅读 · 0 评论 -
报错处理: No module named 'pygame'
1.卸载python,原来安装的目录是默认安装目录,且为隐藏目录2.安装pygame不再使用命令行模式安装,而是使用pycharm安装3.重新安装python之后,启动pycharm需要重新配置解释器环境File-setting-Project interpreter,点击齿轮-showall,这时注意,需要新建一个文件夹作为环境文件夹。4.安装pygame.通过File-setting-Proj...原创 2018-07-15 08:41:45 · 26802 阅读 · 0 评论 -
Python编程:测试函数报错问题处理
测试函数是用于自动化测试,使用python模块中的unittest中的工具来测试附上书中摘抄来的代码:#coding=utf-8import unittestfrom name_function import get_formatted_name class NamesTestCase(unittest.TestCase): def test_first_last_...转载 2018-07-13 22:37:19 · 1399 阅读 · 0 评论 -
报错处理: __init__() missing 1 required positional argument: 'on_delete'
在django2.0后,定义外键和一对一关系的时候需要加on_delete选项,此参数为了避免两个表里的数据不一致问题,不然会报错:TypeError: __init__() missing 1 required positional argument: 'on_delete'举例说明:user=models.OneToOneField(User)owner=models.ForeignK...原创 2018-07-24 22:40:29 · 3660 阅读 · 0 评论 -
报错处理:新建一个名为learning_log的项目
Python编程:从入门到实践第十八章18.1.6❶(ll_env)learning_log$ django-admin.py startproject learning_log .❷ (ll_env)learning_log$ lslearning_log ll_env manage.py❸ (ll_env)learning_log$ ls learning_log__init__....原创 2018-07-23 22:46:01 · 3236 阅读 · 1 评论 -
Can't connect to MySQL server on 'localhost' (10061)
原文地址:https://blog.csdn.net/xiaoshaohui1234/article/details/72947707一、问题描述在启动MYSQL时出现问题:“ERROR 2003 (HY000): Can’t connect to MySQL server on ‘localhost’ (10061)”,情况如图: 二、问题分析从错误的提示中可以看出MySQL服务没有启动,因此只...转载 2018-07-13 22:36:34 · 186 阅读 · 0 评论 -
爬虫:模拟浏览器请求头设置
前一篇文章报错的第二种处理方法:headers = { "Accept" : "application/jason, text/javascript, */*; q = 0.01", "X-Request-With" : "XMLHttpRequest", "User-Agent":"Mozilla/5.0 (Windows NT 10.0; ...) Gecko/2010.原创 2018-06-09 19:14:51 · 3365 阅读 · 0 评论 -
爬虫:模拟浏览器报错解决方法
报错:UnicodeEncodeError: 'latin-1' codec can't encode character '\u2026' in position 30: ordinal not in range(256)报错原因:解决方案:去掉...结果:运行正常转载 2018-06-09 18:26:52 · 656 阅读 · 1 评论 -
报错处理:cannot import name 'cross_validation' from 'sklearn'
在用from sklearn import cross_validation时,报错为cannot import name 'cross_validation' from 'sklearn'。查询得知说是新版sklearn中cross_validation被废弃,可以测试了几个网上的解决办法,依然报错。如是使用Everything查找cross_validation.py文件,我的电脑中其...原创 2018-11-26 07:59:26 · 20734 阅读 · 8 评论