我正在尝试导入 openpyxl 以开始学习它,但是每当我尝试导入它时,它都会吐出这个
Traceback (most recent call last):
File "D:\Py\test.py", line 3, in <module>
import openpyxl
File "C:\Users\[my_username]\AppData\Local\Programs\Python\Python310\lib\site-packages\openpyxl\__init__.py", line 6, in <module>
from openpyxl.workbook import Workbook
File "C:\Users\[my_username]\AppData\Local\Programs\Python\Python310\lib\site-packages\openpyxl\workbook\__init__.py", line 4, in <module>
from .workbook import Workbook
File "C:\Users\[my_username]\AppData\Local\Programs\Python\Python310\lib\site-packages\openpyxl\workbook\workbook.py", line 17, in <module>
from openpyxl.writer.excel import save_workbook
File "C:\Users\[my_username]\AppData\Local\Programs\Python\Python310\lib\site-packages\openpyxl\writer\excel.py", line 31, in <module>
from openpyxl.packaging.manifest import Manifest
File "C:\Users\[my_username]\AppData\Local\Programs\Python\Python310\lib\site-packages\openpyxl\packaging\manifest.py", line 42, in <module>
mimetypes = MimeTypes()
File "C:\Users\[my_username]\AppData\Local\Programs\Python\Python310\lib\mimetypes.py", line 74, in __init__
init()
File "C:\Users\[my_username]\AppData\Local\Programs\Python\Python310\lib\mimetypes.py", line 368, in init
db.read_windows_registry()
File "C:\Users\[my_username]\AppData\Local\Programs\Python\Python310\lib\mimetypes.py", line 253, in read_windows_registry
_mimetypes_read_windows_registry(add_type)
PermissionError:[WinError 5] 访问被拒绝
如果有帮助的话,这是我使用的所有代码
import openpyxl
我尝试过:
没有影响
半解。
我发现从 python 3.10.8 降级到 3.7 消除了错误。 3.8 之后的所有内容都会崩溃。仍然完全不知道他们为什么崩溃。
也许重新安装软件包适用于您的情况。
pip uninstall openpyxl
pip install openpyxl
随着Github、Python Discussion1和Python Discussion2中的错误报告,当前的解决方法是对其进行评论。