※This article is based on Python 3.7.3
发生下面的错误
Traceback (most recent call last): File "jd.py", line 50, in <module> df.to_excel('D:\python\news.xlsx') File "C:\Users\th\AppData\Local\Programs\Python\Python37\lib\site-packages\pandas\core\generic.py", line 2127, in to_excel engine=engine) File "C:\Users\th\AppData\Local\Programs\Python\Python37\lib\site-packages\pandas\io\formats\excel.py", line 656, in write writer = ExcelWriter(_stringify_path(writer), engine=engine) File "C:\Users\th\AppData\Local\Programs\Python\Python37\lib\site-packages\pandas\io\excel.py", line 1204, in __init__ from openpyxl.workbook import Workbook ModuleNotFoundError: No module named 'openpyxl'
看到“ModuleNotFoundError”的错误,缺少什么就像下面一样安装什么。
pip install openpyxl
File => Settings => Project:项目名称 => Python Interpreter => 点击齿轮图标
在“Virtualenv Environment”里面选中“Existing Environment”填入Python.exe的路径后回到“ Python Interpreter”页面
点击 + 加号,填写需要安装的安装包,安装即可
コメント: