[Python] WinError 5, When importing openpyxl

Discussão em 'Python' iniciado por Stack, Novembro 22, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to import openpyxl in order to start learning it, however whenever I try to import it it spits out this

    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] Access is denied

    In case it helps here is all the code I used

    import openpyxl


    I have tried to:

    • Upgrade pip
    • Take ownership of AppData\Local\Programs\Python
    • Install pydirectory
    • Run file as administrator
    • Run file from administrator CMD
    • Uninstalling and Reinstalling openpyxl

    With no impact

    Half-Solution.

    I found that downgrading from python 3.10.8 to 3.7 removed the error. Everything 3.8 onward crashes. Still have absolutely no clue as to why they crash.

    Continue reading...

Compartilhe esta Página