背景介绍

最近,尝试着用pythoncharm 这个All-star IDE来搞一搞Django,于是乎,下载专业版,PJ等等一系列操作之后,终于得偿所愿。可以开工了。

错误

在园子里找了一篇初学者的教程,按照教程上面的指导,一步一步往下走,一路上都很顺利。但是到了启动django server的时候出现了意外。

错误信息如下:

/home/ct/PycharmProjects/mysite/venv/bin/python /home/ct/PycharmProjects/mysite/manage.py runserver 127.0.0.1:
Traceback (most recent call last):
File "/home/ct/PycharmProjects/mysite/manage.py", line , in <module>
execute_from_command_line(sys.argv)
File "/home/ct/PycharmProjects/mysite/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line , in execute_from_command_line
utility.execute()
File "/home/ct/PycharmProjects/mysite/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line , in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/ct/PycharmProjects/mysite/venv/local/lib/python2.7/site-packages/django/core/management/base.py", line , in run_from_argv
self.execute(*args, **cmd_options)
File "/home/ct/PycharmProjects/mysite/venv/local/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line , in execute
super(Command, self).execute(*args, **options)
File "/home/ct/PycharmProjects/mysite/venv/local/lib/python2.7/site-packages/django/core/management/base.py", line , in execute
output = self.handle(*args, **options)
File "/home/ct/PycharmProjects/mysite/venv/local/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line , in handle
if not settings.DEBUG and not settings.ALLOWED_HOSTS:
File "/home/ct/PycharmProjects/mysite/venv/local/lib/python2.7/site-packages/django/conf/__init__.py", line , in __getattr__
self._setup(name)
File "/home/ct/PycharmProjects/mysite/venv/local/lib/python2.7/site-packages/django/conf/__init__.py", line , in _setup
% (desc, ENVIRONMENT_VARIABLE)) django.core.exceptions.ImproperlyConfigured: Requested setting DEBUG, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.

Process finished with exit code

分析原因

最初,分析原因猜测是Django的安装出了问题; 但是,使用 terminal来启动django, 一切正常啊。

ct@ubuntu:~/PycharmProjects/mysite$ python manage.py runserver 127.0.0.1:
Performing system checks... System check identified no issues ( silenced). You have unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
Run 'python manage.py migrate' to apply them. April , - ::
Django version 1.11, using settings 'mysite.settings' Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

思考了以后,感觉还是 pythoncharm 里,关于django的设置出了问题。于是打开IDE中的配置,发现缺失了 “DJANGO_SETTINGS_MODULE” 的配置

解决方法

顺着这个思路,一直找解决方案,终于找到了如何设置django项目的配置。

export DJANGO_SETTINGS_MODULE=mysite.settings

其实也就是添加环境变量罢了,只不过在pythoncharm中,我们需要将环境变量添加到IDE里面。。。

点击OK后,再次在pythoncharm里运行项目,这次成功啦!!

参考资料:

https://stackoverflow.com/questions/26082128/improperlyconfigured-you-must-either-define-the-environment-variable-django-set

记录一下加深记忆的同时也希望能帮到其他人!! 感谢大家的收看, bye~~

pythoncharm 中解决启动server时出现 “django.core.exceptions.ImproperlyConfigured: Requested setting DEBUG, but settings are not configured”的错误的更多相关文章

  1. 关于Django报错django.core.exceptions.ImproperlyConfigured: Requested setting DEBUG, but settings are not configure

    报错代码:django.core.exceptions.ImproperlyConfigured: Requested setting DEFAULT_INDEX_TABLESPACE, but se ...

  2. django.core.exceptions.ImproperlyConfigured: Requested setting DEFAULT_INDEX_TABLESPACE, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call

    Error info: django.core.exceptions.ImproperlyConfigured: Requested setting DEFAULT_INDEX_TABLESPACE, ...

  3. django调用py报错 django.core.exceptions.ImproperlyConfigured: Requested setting DEFAULT_INDEX_TABLESPACE, but settings are not configured.

    完整报错信息如下 django.core.exceptions.ImproperlyConfigured: Requested setting DEFAULT_INDEX_TABLESPACE, bu ...

  4. celery开启worker报错django.core.exceptions.ImproperlyConfigured: Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE o

    其实挺简单的问题,但花了自己一个下午来解决,先是浏览各种博客,无果:没办法,然后去看celery官方文档,无果,近乎绝望,最后仔细看代码,找到问题所在(如下),自学狗这效率...... 下面是自己ta ...

  5. 解决:django.core.exceptions.ImproperlyConfigured: Requested setting INSTALLED_APPS, but settings are not 的方法

    错误类型: 该错误是在在创建Django工程时出现遇到的错误 完整报错信息:(博文标题输入长度有限制) django.core.exceptions.ImproperlyConfigured: Req ...

  6. django.core.exceptions.ImproperlyConfigured: Requested setting DEFAULT_INDEX_TABLESPACE的解决办法(转)

    在python的开发中,遇到了这个错误: django.core.exceptions.ImproperlyConfigured: Requested setting DEFAULT_INDEX_TA ...

  7. python基于Django框架编译报错“django.core.exceptions.ImproperlyConfigured”的解决办法?

    下面是我具体遇到的问题和解决方法: 错误详细信息: django.core.exceptions.ImproperlyConfigured: Requested setting DEFAULT_IND ...

  8. django中执行py报错Requested setting DEFAULT_INDEX_TABLESPACE, but settings are not configured

    https://blog.csdn.net/heybob/article/details/49684261 django代码下面直接run的时候报错: django.core.exceptions.I ...

  9. Django2.2连接mysql数据库出现django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.3 or newer is required; you have 0.7.11.None问题

    在使用Django2.2开发的时候,想要使用mysql数据库,在settings.py文件中更改命令: DATABASES = { 'default': { 'ENGINE': 'django.db. ...

随机推荐

  1. 【linux之进程管理,系统监控】

    一.进程管理 前台进程:一般是指占据着标准输入和/或标准输出的进程后台进程:不占据默认开启的进程都是前台进程ctrl+C 中断ctrl+z 从前台转入后台bg 后台进程编号 让其在后台运行ls -R ...

  2. 牛客小白月赛1 A-简单题

    描述 Etéreo 是个爱学习的好孩子.在年假期间,他依然热情于数学.他最近发现了一个高大上的东西:,他觉得这里的  非常的厉害!然后他又告诉你:,,他会告诉你  和  ,想请你告诉他  的值.当然这 ...

  3. 【python学习笔记】10.充电时刻

    [python学习笔记]10.充电时刻 任何python都可以作为模块倒入 *.pyc:平台无关的经过编译的的python文件, 模块在第一次导入到程序中时被执行,包括定义类,函数,变量,执行语句 可 ...

  4. APNS IOS 消息推送沙盒模式和发布模式

    在做.NET向IOS设备的App进行消息推送时候,采用的是PushSharp开源类库进行消息的推送,而在开发过程中,采用的是测试版本的app,使用的是测试的p12证书采用的是ApnsConfigura ...

  5. BZOJ1565 植物大战僵尸 题解

    题目内容: 题目分析:有选A则必须选B这样的限制条件,可以发现这是最大权闭合子图模型,考虑环的情况,可以推测需要拓扑判环. 代码: #include<bits/stdc++.h> usin ...

  6. Starting a Gradle Daemon, 5 busy and 1 incompatible and 1 stopped Daemons could not be reused, use --status for details FAILURE: Build failed with an exception. * What went wrong: Could not dispatch

    执行gradle build出的问题,查看hs_err_pid11064.log日志文件发现,是电脑的RAM不足导致

  7. python爬微信公众号前10篇历史文章(4)-正则表达式RegularExpressionPattern

    正则表达式(regular expression)描述了一种字符串匹配的模式(pattern),可以用来检查一个串是否含有某种子串.将匹配的子串替换或者从某个串中取出符合某个条件的子串等. Pytho ...

  8. VS,连接到oracle 报要升级到8.多少版本的错

    1:确定服务器的oracle版本 2:本地的客户端版本要和服务器一致 3:操作系统位数要一致

  9. selenium 基础(一)

    selenium安装 pip install selenium selenium操作浏览器原理 早期selenium 1.0 用的selenium RC, 后来selenum2集合了selenium1 ...

  10. LinkedList源码解析(JDK1.8)

    package java.util; import java.util.function.Consumer; /** * LinkedList是List和Deque接口的双向链表的实现.实现了所有可选 ...