in Vscode, RuntimeError: 'path' must be None or a list, not <class '_frozen_importlib_external._NamespacePath'>

Question:

I use Ubuntu and Vscode. In my Django project, I’ve tried to run python manage.py process_tasks command and I got this error below.

Traceback (most recent call last):
  File "manage.py", line 21, in <module>
    main()
  File "manage.py", line 17, in main
    execute_from_command_line(sys.argv)
  File "/home/../venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "/home/../venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 375, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/../venv/lib/python3.6/site-packages/django/core/management/base.py", line 323, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/../venv/lib/python3.6/site-packages/django/core/management/base.py", line 364, in execute
    output = self.handle(*args, **options)
  File "/home/../venv/lib/python3.6/site-packages/background_task/management/commands/process_tasks.py", line 123, in handle
    self.run(*args, **options)
  File "/home/../venv/lib/python3.6/site-packages/background_task/management/commands/process_tasks.py", line 96, in run
    autodiscover()
  File "/home/../venv/lib/python3.6/site-packages/background_task/tasks.py", line 317, in autodiscover
    imp.find_module('tasks', app_path)
  File "/usr/lib/python3.6/imp.py", line 271, in find_module
    "not {}".format(type(path)))
RuntimeError: 'path' must be None or a list, not <class '_frozen_importlib_external._NamespacePath'>

How can I fix this?

Asked By: Aslı Kök

||

Answers:

It looks like you are missing an __init__.py file somewhere in your project; looks like a tasks directory is probably the culprit.

Answered By: Brett Cannon

Ran into this issue as well.

Turns out one of the Folder directories in my Django project did not have the init.py file that changes the folder into a package.

This causes the error to be thrown. Solution: go through each folder and manually check if the file was there.

Answered By: kpdebree