image
- NameError: name ‘os’ is not defined
解決方法:把import os放到其他import之后
import numpy as np
import xlrd
import matplotlib.pyplot as plt
import os
- ImportError: No module named 'xlrd'
解決方法:win + R 打開終端,輸入 "cmd" ,執(zhí)行下面。
pip install xlrd -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
python
import xlrd
如果還是不可以,查看下 Visual Studio Code 的 python 版本與 終端執(zhí)行的是否一致,我的電腦上安裝了三個(gè)版本的 python ,所以就踩到這個(gè)坑了。
如果不一致,解決方法:在 Visual Studio Code ,按 Ctrl + Shift +P , 出來搜索框,輸入 settings.json, 選擇如下。把 python 的地址改成和終端執(zhí)行的一致(終端的 python 安裝位置用 where python 命令即可查到)。
image.png
-
xlrd.biffh.XLRDError: Excel xlsx file; not supported
xlrd
image.png anaconda 無法打開
第一步:使用管理員運(yùn)行:conda prompt
第二步:執(zhí)行命令 conda update anaconda-navigator
第三步:執(zhí)行anaconda-navigator --reset
第四步:執(zhí)行conda update anaconda-client
第五步:執(zhí)行conda update -f anaconda-client
第六步:成功打開。
- Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None))
pip install keras -i http://pypi.douban.com/simple --trusted-host pypi.douban.com