pythontkintertkcalendar

Import "tkcalendar" could not be resolved


I am building a GUI on TKinter and wanted to include a calendar to pick dates. I had imported tkcalendar and followed he steps mentioned in its documentation to install tkcalendar. But, it shows a problem while running the code in VSCode while importing.

from tkcalendar import Calendar

Import "tkcalendar" could not be resolved

I have looked up the documentation and several other pages but couldn't resolve the error. Please help me.

Ubuntu 20.04 No virtual env


Solution

  • Open the VS Code Integrated Terminal using the Ctrl+Shift+` shortcut and type the command which python. Then locate the settings.json file inside the .vscode folder of your project and specify the python interpreter path as shown below:

    "python.pythonPath": "output_of_which_python_command"
    

    Then open VS Code Integrated Terminal again and type the command python -m pip freeze to check if tkcalendar is actually installed. If not, then type the command pip install tkcalendar.