[Python] No module named openpyxl - Python 3.6

Discussão em 'Python' iniciado por Stack, Fevereiro 12, 2025.

  1. Stack

    Stack Membro Participativo

    I have virtual environment setup for my project, where i run python 3.6 with openpyxl module installed inside virtual enviroment.

    I wrote a simple test program and when i run it within VIsual Studio Code editor i get this error:

    No module named 'openpyxl'


    However if i run the program from the command prompt, inside virtual environment, it executes without any error. I have configured Visual Studio Code to use my virtual environment path with this line:

    "python.pythonPath": "C:\\Users\\Nermin\\Desktop\\EA-Monthly-Report\\Scripts"


    Why is Visual Studio Code complaining that the openpyxl module does not exist when that is not true?

    '''Testing openpyxl modlue for python'''
    from openpyxl import Workbook

    def test_workbook():
    '''
    Testing openpyxl
    '''

    work_book = Workbook()
    work_sheet = work_book.active
    work_sheet.title = "EA Monthly Report"
    work_sheet['A1'] = 'Test Data'
    work_book.save('test.xlsx')

    #Run program
    test_workbook()

    Continue reading...

Compartilhe esta Página