django-ModuleNotFoundError:没有名为“ config”的模块

时间:2019-08-05 14:33:57

标签: django python-3.x django-rest-framework virtualenv

我是python和django的新手。每当我尝试任何django命令时,都会收到此错误。以下是我尝试的步骤:



    [namespace] user@tux:~/Workspace/udemy$ python3 -m venv restapi-basics
    [namespace] user@tux:~/Workspace/udemy$ cd restapi-basics/
    [namespace] user@tux:~/Workspace/udemy/restapi-basics$ source bin/activate
    (restapi-basics) [namespace] user@tux:~/Workspace/udemy/restapi-basics$ which python
    /home/user/Workspace/udemy/restapi-basics/bin/python
    (restapi-basics) [namespace] user@tux:~/Workspace/udemy/restapi-basics$ python --version
    Python 3.6.8
    (restapi-basics) [namespace] user@tux:~/Workspace/udemy/restapi-basics$ which pip
    /home/user/Workspace/udemy/restapi-basics/bin/pip
    (restapi-basics) [namespace] user@tux:~/Workspace/udemy/restapi-basics$ pip --version
    pip 9.0.1 from /home/user/Workspace/udemy/restapi-basics/lib/python3.6/site-packages (python 3.6)
    (restapi-basics) [namespace] user@tux:~/Workspace/udemy/restapi-basics$ pip install django djangorestframework djangorestframework-jwt
    Collecting django
      Downloading https://files.pythonhosted.org/packages/d6/57/66997ca6ef17d2d0f0ebcd860bc6778095ffee04077ca8985928175da358/Django-2.2.4-py3-none-any.whl (7.5MB)
        100% |████████████████████████████████| 7.5MB 193kB/s 
    Collecting djangorestframework
      Downloading https://files.pythonhosted.org/packages/af/2a/055e65e1aa25cc2726d68d78b859a7b5955c673bc5e4646b205c21e05b25/djangorestframework-3.10.2-py3-none-any.whl (908kB)
        100% |████████████████████████████████| 911kB 748kB/s 
    Collecting djangorestframework-jwt
      Downloading https://files.pythonhosted.org/packages/2b/cf/b3932ad3261d6332284152a00c3e3a275a653692d318acc6b2e9cf6a1ce3/djangorestframework_jwt-1.11.0-py2.py3-none-any.whl
    Collecting pytz (from django)
      Downloading https://files.pythonhosted.org/packages/87/76/46d697698a143e05f77bec5a526bf4e56a0be61d63425b68f4ba553b51f2/pytz-2019.2-py2.py3-none-any.whl (508kB)
        100% |████████████████████████████████| 512kB 928kB/s 
    Collecting sqlparse (from django)
      Downloading https://files.pythonhosted.org/packages/ef/53/900f7d2a54557c6a37886585a91336520e5539e3ae2423ff1102daf4f3a7/sqlparse-0.3.0-py2.py3-none-any.whl
    Collecting PyJWT=1.5.2 (from djangorestframework-jwt)
      Downloading https://files.pythonhosted.org/packages/87/8b/6a9f14b5f781697e51259d81657e6048fd31a113229cf346880bb7545565/PyJWT-1.7.1-py2.py3-none-any.whl
    Installing collected packages: pytz, sqlparse, django, djangorestframework, PyJWT, djangorestframework-jwt
    Successfully installed PyJWT-1.7.1 django-2.2.4 djangorestframework-3.10.2 djangorestframework-jwt-1.11.0 pytz-2019.2 sqlparse-0.3.0
    (restapi-basics) [namespace] user@tux:~/Workspace/udemy/restapi-basics$ which django-admin
    /home/user/Workspace/udemy/restapi-basics/bin/django-admin
    (restapi-basics) [namespace] user@tux:~/Workspace/udemy/restapi-basics$ django-admin startproject cfehome
    (restapi-basics) [namespace] user@tux:~/Workspace/udemy/restapi-basics$ cd cfehome/
    (restapi-basics) [namespace] user@tux:~/Workspace/udemy/restapi-basics/cfehome$ ls
    cfehome  manage.py
    (restapi-basics) [namespace] user@tux:~/Workspace/udemy/restapi-basics/cfehome$ python manage.py runserver
Traceback (most recent call last):
      File "/home/user/Workspace/udemy/restapi-basics/lib/python3.6/site-packages/django/core/management/base.py", line 323, in run_from_argv
        self.execute(*args, cmd_options)
      File "/home/user/Workspace/udemy/restapi-basics/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 60, in execute
        super().execute(*args, options)
      File "/home/user/Workspace/udemy/restapi-basics/lib/python3.6/site-packages/django/core/management/base.py", line 364, in execute
        output = self.handle(*args, options)
      File "/home/user/Workspace/udemy/restapi-basics/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 67, in handle
        if not settings.DEBUG and not settings.ALLOWED_HOSTS:
      File "/home/user/Workspace/udemy/restapi-basics/lib/python3.6/site-packages/django/conf/__init__.py", line 79, in __getattr__
        self._setup(name)
      File "/home/user/Workspace/udemy/restapi-basics/lib/python3.6/site-packages/django/conf/__init__.py", line 66, in _setup
        self._wrapped = Settings(settings_module)
      File "/home/user/Workspace/udemy/restapi-basics/lib/python3.6/site-packages/django/conf/__init__.py", line 157, in __init__
        mod = importlib.import_module(self.SETTINGS_MODULE)
      File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "", line 994, in _gcd_import
      File "", line 971, in _find_and_load
      File "", line 941, in _find_and_load_unlocked
      File "", line 219, in _call_with_frames_removed
      File "", line 994, in _gcd_import
      File "", line 971, in _find_and_load
      File "", line 941, in _find_and_load_unlocked
      File "", line 219, in _call_with_frames_removed
      File "", line 994, in _gcd_import
      File "", line 971, in _find_and_load
      File "", line 953, in _find_and_load_unlocked
    ModuleNotFoundError: No module named 'config'

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "manage.py", line 21, in 
        main()
      File "manage.py", line 17, in main
        execute_from_command_line(sys.argv)
      File "/home/user/Workspace/udemy/restapi-basics/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
        utility.execute()
      File "/home/user/Workspace/udemy/restapi-basics/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/user/Workspace/udemy/restapi-basics/lib/python3.6/site-packages/django/core/management/base.py", line 336, in run_from_argv
        connections.close_all()
      File "/home/user/Workspace/udemy/restapi-basics/lib/python3.6/site-packages/django/db/utils.py", line 219, in close_all
        for alias in self:
      File "/home/user/Workspace/udemy/restapi-basics/lib/python3.6/site-packages/django/db/utils.py", line 213, in __iter__
        return iter(self.databases)
      File "/home/user/Workspace/udemy/restapi-basics/lib/python3.6/site-packages/django/utils/functional.py", line 80, in __get__
        res = instance.__dict__[self.name] = self.func(instance)
      File "/home/user/Workspace/udemy/restapi-basics/lib/python3.6/site-packages/django/db/utils.py", line 147, in databases
        self._databases = settings.DATABASES
      File "/home/user/Workspace/udemy/restapi-basics/lib/python3.6/site-packages/django/conf/__init__.py", line 79, in __getattr__
        self._setup(name)
      File "/home/user/Workspace/udemy/restapi-basics/lib/python3.6/site-packages/django/conf/__init__.py", line 66, in _setup
        self._wrapped = Settings(settings_module)
      File "/home/user/Workspace/udemy/restapi-basics/lib/python3.6/site-packages/django/conf/__init__.py", line 157, in __init__
        mod = importlib.import_module(self.SETTINGS_MODULE)
      File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "", line 994, in _gcd_import
      File "", line 971, in _find_and_load
      File "", line 941, in _find_and_load_unlocked
      File "", line 219, in _call_with_frames_removed
      File "", line 994, in _gcd_import
      File "", line 971, in _find_and_load
      File "", line 941, in _find_and_load_unlocked
      File "", line 219, in _call_with_frames_removed
      File "", line 994, in _gcd_import
      File "", line 971, in _find_and_load
      File "", line 953, in _find_and_load_unlocked
    ModuleNotFoundError: No module named 'config'
    (restapi-basics) [namespace] user@tux:~/Workspace/udemy/restapi-basics/cfehome$ python manage.py migrate
    Traceback (most recent call last):
      File "/home/user/Workspace/udemy/restapi-basics/lib/python3.6/site-packages/django/core/management/base.py", line 323, in run_from_argv
        self.execute(*args, cmd_options)
      File "/home/user/Workspace/udemy/restapi-basics/lib/python3.6/site-packages/django/core/management/base.py", line 361, in execute
        self.check()
      File "/home/user/Workspace/udemy/restapi-basics/lib/python3.6/site-packages/django/core/management/base.py", line 390, in check
        include_deployment_checks=include_deployment_checks,
      File "/home/user/Workspace/udemy/restapi-basics/lib/python3.6/site-packages/django/core/management/commands/migrate.py", line 64, in _run_checks
        issues = run_checks(tags=[Tags.database])
      File "/home/user/Workspace/udemy/restapi-basics/lib/python3.6/site-packages/django/core/checks/registry.py", line 72, in run_checks
        new_errors = check(app_configs=app_configs)
      File "/home/user/Workspace/udemy/restapi-basics/lib/python3.6/site-packages/django/core/checks/database.py", line 9, in check_database_backends
        for conn in connections.all():
      File "/home/user/Workspace/udemy/restapi-basics/lib/python3.6/site-packages/django/db/utils.py", line 216, in all
        return [self[alias] for alias in self]
      File "/home/user/Workspace/udemy/restapi-basics/lib/python3.6/site-packages/django/db/utils.py", line 213, in __iter__
        return iter(self.databases)
      File "/home/user/Workspace/udemy/restapi-basics/lib/python3.6/site-packages/django/utils/functional.py", line 80, in __get__
        res = instance.__dict__[self.name] = self.func(instance)
      File "/home/user/Workspace/udemy/restapi-basics/lib/python3.6/site-packages/django/db/utils.py", line 147, in databases
        self._databases = settings.DATABASES
      File "/home/user/Workspace/udemy/restapi-basics/lib/python3.6/site-packages/django/conf/__init__.py", line 79, in __getattr__
        self._setup(name)
      File "/home/user/Workspace/udemy/restapi-basics/lib/python3.6/site-packages/django/conf/__init__.py", line 66, in _setup
        self._wrapped = Settings(settings_module)
      File "/home/user/Workspace/udemy/restapi-basics/lib/python3.6/site-packages/django/conf/__init__.py", line 157, in __init__
        mod = importlib.import_module(self.SETTINGS_MODULE)
      File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "", line 994, in _gcd_import
      File "", line 971, in _find_and_load
      File "", line 941, in _find_and_load_unlocked
      File "", line 219, in _call_with_frames_removed
      File "", line 994, in _gcd_import
      File "", line 971, in _find_and_load
      File "", line 941, in _find_and_load_unlocked
      File "", line 219, in _call_with_frames_removed
      File "", line 994, in _gcd_import
      File "", line 971, in _find_and_load
      File "", line 953, in _find_and_load_unlocked
    ModuleNotFoundError: No module named 'config'

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "manage.py", line 21, in 
        main()
      File "manage.py", line 17, in main
        execute_from_command_line(sys.argv)
      File "/home/user/Workspace/udemy/restapi-basics/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
        utility.execute()
      File "/home/user/Workspace/udemy/restapi-basics/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/user/Workspace/udemy/restapi-basics/lib/python3.6/site-packages/django/core/management/base.py", line 336, in run_from_argv
        connections.close_all()
      File "/home/user/Workspace/udemy/restapi-basics/lib/python3.6/site-packages/django/db/utils.py", line 219, in close_all
        for alias in self:
      File "/home/user/Workspace/udemy/restapi-basics/lib/python3.6/site-packages/django/db/utils.py", line 213, in __iter__
        return iter(self.databases)
      File "/home/user/Workspace/udemy/restapi-basics/lib/python3.6/site-packages/django/utils/functional.py", line 80, in __get__
        res = instance.__dict__[self.name] = self.func(instance)
      File "/home/user/Workspace/udemy/restapi-basics/lib/python3.6/site-packages/django/db/utils.py", line 147, in databases
        self._databases = settings.DATABASES
      File "/home/user/Workspace/udemy/restapi-basics/lib/python3.6/site-packages/django/conf/__init__.py", line 79, in __getattr__
        self._setup(name)
      File "/home/user/Workspace/udemy/restapi-basics/lib/python3.6/site-packages/django/conf/__init__.py", line 66, in _setup
        self._wrapped = Settings(settings_module)
      File "/home/user/Workspace/udemy/restapi-basics/lib/python3.6/site-packages/django/conf/__init__.py", line 157, in __init__
        mod = importlib.import_module(self.SETTINGS_MODULE)
      File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "", line 994, in _gcd_import
      File "", line 971, in _find_and_load
      File "", line 941, in _find_and_load_unlocked
      File "", line 219, in _call_with_frames_removed
      File "", line 994, in _gcd_import
      File "", line 971, in _find_and_load
      File "", line 941, in _find_and_load_unlocked
      File "", line 219, in _call_with_frames_removed
      File "", line 994, in _gcd_import
      File "", line 971, in _find_and_load
      File "", line 953, in _find_and_load_unlocked
    ModuleNotFoundError: No module named 'config'


0 个答案:

没有答案