背景介绍

最近,尝试着用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. datatable 分页实例

    1.使用datatable前台分页,需要后台返回全部数据,返回lisit 2.如果是后台分页 则后台需要获取分页参数,页面中要加 "searchable":true,  " ...

  2. iOS工具——Xcode9无证书真机调试

    入坑iOS开发这么久,一直都是在模拟器上运行,公司的项目也都有公司的开发者账号进行真机调试.但是很多时候在网上download一些demo想在真机上运行看一下效果的时候都没法成行,今天抽空好好研究和学 ...

  3. Linux tar包安装Nginx-1.7.6 (yum方式安装依赖)

    1.首先安装依赖包(依赖包有点多,我们采用yum的方式来安装) yum -y install zlib zlib-devel openssl openssl-devel pcre pcre-devel ...

  4. Firefox扩展安装

    firefox扩展和chrome扩展非常相似,甚至兼容.因总结过chrome扩展的开发,这里不提,本篇谈谈firefox扩展的安装. 1.打包 所谓的打包,就是压缩,利用普通的右键压缩文件夹,这样形成 ...

  5. Java 多线程之哪个对象才是锁?

    问题背景 在感觉正常的使用ArrayList的迭代删除的操作的时候,发现了如下的崩溃日志: Caused by: java.util.ConcurrentModificationException a ...

  6. 关于设计SQL表的一些问题

    1.设计问题: 当sql语句输入时,需要输入表名,表名内需要输入日期,而且譬如"第二天安装"这种,sql语句中有两个地方需要输入日期,一个是昨天,一个是今天,这种情况将输入日期的部 ...

  7. 3.2.2 break 与 continue 语句

    break 语句和 continue语句在while循环和for循环中都可以使用,并且一般常与选择结构结合使用.一旦break语句被执行,将使得break语句所属层次的循环提前结束.continue语 ...

  8. 【MyBatis】MyBatis自动生成代码查询之爬坑记

    前言 项目使用SSM框架搭建Web后台服务,前台后使用restful api,后台使用MyBatisGenerator自动生成代码,在前台使用关键字进行查询时,遇到了一些很宝贵的坑,现记录如下.为展示 ...

  9. MSIL实用指南-局部变量的声明、保存和加载

    这一篇讲解方法内的局部变量是怎么声明.怎样保存.怎样加载的. 声明局部变量声明用ILGenerator的DeclareLocal方法,参数是局部变量的数据类型,得到一个局部变量对应的创建类LocalB ...

  10. phpstorm激活码生成器地址

    http://idea.qinxi1992.cn/ 写在windows/system32/drivers/etc/hosts里 0.0.0.0 account.jetbrains.com 激活码位置: ...