skip to Main Content

I am on windows 10 and everytime i try to run my code with customtkinter in vscode I get:

ModuleNotFoundError: No module named 'packaging'

I tried reinstalling Python, I watched some tutorials, but it still doesn’t work.

My code:

import tkinter
import customtkinter
from pytube import YouTube

# System Settings
customtkinter.set_appearance_mode("System")
customtkinter.set_default_color_theme("blue")


app = customtkinter.CTk()
app.geometry("720x480")
app.title("YouTube Downloader")



# Run app
app.mainloop()

PS C:UsersdbravDesktoppython>  & 'C:Usersdbravpyverpy3121python.exe' 'c:Usersdbrav.vscodeextensionsms-python.python-2023.22.1pythonFileslibpythondebugpyadapter/../..debugpylauncher' '51762' '--' 'C:UsersdbravDesktoppythonmain.py' 
Traceback (most recent call last):
  File "C:Usersdbravpyverpy3121Librunpy.py", line 198, in _run_module_as_main
    return _run_code(code, main_globals, None,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:Usersdbravpyverpy3121Librunpy.py", line 88, in _run_code
    exec(code, run_globals)
  File "c:Usersdbrav.vscodeextensionsms-python.python-2023.22.1pythonFileslibpythondebugpyadapter/../..debugpylauncher/../..debugpy__main__.py", line 39, in <module>
    cli.main()
  File "c:Usersdbrav.vscodeextensionsms-python.python-2023.22.1pythonFileslibpythondebugpyadapter/../..debugpylauncher/../..debugpy/..debugpyservercli.py", line 430, in main
    run()
  File "c:Usersdbrav.vscodeextensionsms-python.python-2023.22.1pythonFileslibpythondebugpyadapter/../..debugpylauncher/../..debugpy/..debugpyservercli.py", line 284, in run_file
    runpy.run_path(target, run_name="__main__")
  File "c:Usersdbrav.vscodeextensionsms-python.python-2023.22.1pythonFileslibpythondebugpy_vendoredpydevd_pydevd_bundlepydevd_runpy.py", line 321, in run_path
    return _run_module_code(code, init_globals, run_name,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:Usersdbrav.vscodeextensionsms-python.python-2023.22.1pythonFileslibpythondebugpy_vendoredpydevd_pydevd_bundlepydevd_runpy.py", line 135, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "c:Usersdbrav.vscodeextensionsms-python.python-2023.22.1pythonFileslibpythondebugpy_vendoredpydevd_pydevd_bundlepydevd_runpy.py", line 124, in _run_code
    exec(code, run_globals)
  File "C:UsersdbravDesktoppythonmain.py", line 2, in <module>
    import customtkinter
  File "C:UsersdbravAppDataRoamingPythonPython312site-packagescustomtkinter__init__.py", line 10, in <module>
    from .windows.widgets.appearance_mode import AppearanceModeTracker
  File "C:UsersdbravAppDataRoamingPythonPython312site-packagescustomtkinterwindows__init__.py", line 1, in <module>
    from .ctk_tk import CTk
  File "C:UsersdbravAppDataRoamingPythonPython312site-packagescustomtkinterwindowsctk_tk.py", line 7, in <module>
    from packaging import version
ModuleNotFoundError: No module named 'packaging'

2

Answers


  1. This was usually caused by the incorrect Python intrepreter.

    Ensure that you’ve chosen the correct python interpreter.

    You can use shortcuts Ctrl+Shift+P and type Python: Select Interpreter to choose the python interpreter which you installed the package in.

    Login or Signup to reply.
  2. I fixed the issue by running the following code in the terminal

    pip install packaging

    BINGO. works perfect

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search