1.下载64位python3.7
官网 https://www.python.org/downloads/release/python-370/(较慢)
其他:https://www.pcsoft.com.cn/soft/177699.html
2.python -m pip install --upgrade pip
pip install -i http://pypi.douban.com/simple/ --trusted-host=pypi.douban.com/simple
包
pandas
lxml
pyppeteer 1.0.2
import pyppeteer
pyppeteer.launcher.DEFAULT_ARGS.remove("--enable-automation")#防爬
如果pyppeteer为0.92版本,可能报错Module ‘websockets’ has no attribute ‘client’,换成1.0.2的就行
4.报错解决
参考:解决Python memory error的问题(四种解决方案)
1.Python memory error的问题
一、逐行读取
二、巧用pandas中read_csv的块读取功能
三、扩充虚拟内存
四、更新Pandas和Numpy库为64位
Error tokenizing data
文件如果很大,则 分块读取,参考:Error tokenizing data. C error: out of memory pandas python, large file csv
mylist = []
for chunk in pd.read_csv('train_2011_2012_2013.csv', sep=';', chunksize=20000):
mylist.append(chunk)
big_data = pd.concat(mylist, axis= 0)
del mylist
如果文件很小,可能是因为Python用的是32位的,内存使用超过2G时,会自动终止内存。