Search code examples
pythonvisual-studio-code

I can't import openpyxl in visual studio code


I used the command pip3 install openpyxl, but I'm still getting the error, unresolved import 'openpyxl'.

How I can import the library or fix this error?


Solution

    1. Enter the currently selected environment in the terminal: ( shortcut keys: Ctrl+Shift+` )I use a virtual environment.

      enter image description here

    2. Install the module "openpyxl" in your currently selected VScode environment:

      enter image description here

    3. Reopen this file or reload VSCode after installation:

      enter image description here

    Check the installation:

    We can see the installation package of the module "openpyxl" under ".venv" of the virtual environment used.

    enter image description here