0

widget_tweaks is installed and added in INSTALLED_APPS in my setting.py. If I start the server with python3 manage.py runserver in the terminal it works.

If I start the vscode debugger, I get this error in the Debug Console:

  File "/Users/frank/Dev/MyListApp/env/lib/python3.10/site-packages/django/apps/config.py", line 193, in create
    import_module(entry)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1004, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'widget_tweaks'

My launch.json is:

{
            "name": "MyList",
            "python": "/Users/frank/Dev/MyListApp/env/bin/python3",
            "type": "python",
            "request": "launch",
            "program": "${workspaceFolder}/MyListApp/manage.py",
            "console": "internalConsole",
            "args": [
                "runserver"
            ],
            "django": true,
            "justMyCode": true,
        }

As test: If I use PyCharm, I get the same error when I start the PyCharm debugger.

Where is the problem? In the terminal it works, in the debugger not...

Frank
  • 1
  • you might have added "widget_tweaks" in INSTALLED_APPS array in settings.py or you might have imported the module. – Monish Khatri Sep 13 '22 at 13:48
  • Are you using a venv? Do you activate it when you run from the terminal or is your IDE configured to use a particular venv? – Abdul Aziz Barkat Sep 13 '22 at 13:55
  • @MonishKhatri The error occurs directly while starting the server in debug mode... after adding "widget_tweaks" in INSTALLED_APPS array – Frank Sep 13 '22 at 14:11
  • @AbdulAzizBarkat I'm using env. It works, if I start it in the terminal: (env) Frank-MacBook:MyListApp frank$ python3 manage.py runserver How can I start the debugger in env mode? – Frank Sep 13 '22 at 14:14
  • 1
    Does this answer your question? [How can I set up a virtual environment for Python in Visual Studio Code?](https://stackoverflow.com/questions/54106071/how-can-i-set-up-a-virtual-environment-for-python-in-visual-studio-code) – Abdul Aziz Barkat Sep 13 '22 at 14:24
  • @AbdulAzizBarkat Thanks, now it works! I've deleted my old env and created a new one based on this: https://stackoverflow.com/questions/54106071/how-can-i-set-up-a-virtual-environment-for-python-in-visual-studio-code – Frank Sep 13 '22 at 16:15

0 Answers0