简体   繁体   English

django-admin 找不到设置模块

[英]django-admin cannot find settings module

I'm trying to run django-admin runserver but I get this error:我正在尝试运行django-admin runserver但我收到此错误:

    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'App'

I am using pipenv so I made a .env file in the cwd and I have the DJANGO_SETTINGS_MODULE pointing at src.App.settings I haven't made any sort of modifications, I believe, except running the server once with ./src/manage.py runserver (it automatically created an sqlite3 db).我正在使用 pipenv,所以我在 cwd 中创建了一个.env文件,并且我有指向src.App.settingsDJANGO_SETTINGS_MODULE我相信我没有进行任何类型的修改,除了使用./src/manage.py runserver运行服务器一次./src/manage.py runserver (它自动创建了一个 sqlite3 数据库)。 Here is the file structure image这是文件结构图像

I can run the server perfectly fine if I run it through manage.py though如果我通过 manage.py 运行它,我可以很好地运行服务器

You can use uwsgi to run a django project.您可以使用 uwsgi 运行 django 项目。

First install uwsgi using:首先使用以下命令安装 uwsgi:

pip install uWSGI

Go to project folder and enter this in terminal: Go 到项目文件夹并在终端中输入:

Replace server with whatever is your project name用您的项目名称替换服务器

uwsgi --http :8000 --module Server.wsgi

if you are not interested in install another module then there is no way to runserver locally如果您对安装另一个模块不感兴趣,则无法在本地运行服务器

This is a similar question that was asked, you can check it out.这是一个类似的问题,你可以检查一下。

https://stackoverflow.com/a/32199813/12640905 https://stackoverflow.com/a/32199813/12640905

However, my guess is that the python installation that you're using isn't the same as the pip environment that you're installing the packages into.但是,我的猜测是,您使用的 python 安装与您安装软件包的 pip 环境不同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM