背景介绍
最近,尝试着用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://*.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”的错误的更多相关文章
-
关于Django报错django.core.exceptions.ImproperlyConfigured: Requested setting DEBUG, but settings are not configure
报错代码:django.core.exceptions.ImproperlyConfigured: Requested setting DEFAULT_INDEX_TABLESPACE, but se ...
-
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, ...
-
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 ...
-
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 ...
-
解决:django.core.exceptions.ImproperlyConfigured: Requested setting INSTALLED_APPS, but settings are not 的方法
错误类型: 该错误是在在创建Django工程时出现遇到的错误 完整报错信息:(博文标题输入长度有限制) django.core.exceptions.ImproperlyConfigured: Req ...
-
django.core.exceptions.ImproperlyConfigured: Requested setting DEFAULT_INDEX_TABLESPACE的解决办法(转)
在python的开发中,遇到了这个错误: django.core.exceptions.ImproperlyConfigured: Requested setting DEFAULT_INDEX_TA ...
-
python基于Django框架编译报错“django.core.exceptions.ImproperlyConfigured”的解决办法?
下面是我具体遇到的问题和解决方法: 错误详细信息: django.core.exceptions.ImproperlyConfigured: Requested setting DEFAULT_IND ...
-
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 ...
-
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. ...
随机推荐
-
REDIS源码中一些值得学习的技术细节02
Redis中散列函数的实现: Redis针对整数key和字符串key,采用了不同的散列函数 对于整数key,redis使用了 Thomas Wang的 32 bit Mix Function,实现了d ...
-
linux chomd 学习
chomd -R 777 directory_name :递归地给directory目录下所有文件和子目录的属主分配读的权限 ------2016-10-31 -- source: Linux chm ...
-
Hadoop入门进阶课程9--Mahout介绍、安装与应用案例
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,博主为石山园,博客地址为 http://www.cnblogs.com/shishanyuan ...
-
iOS多线程的初步研究(三)-- NSRunLoop
弄清楚NSRunLoop确实需要花时间,这个类的概念和模式似乎是Apple的平*有(iOS+MacOSX),很难彻底搞懂(iOS没开源,呜呜). 官网的解释是说run loop可以用于处理异步事件, ...
-
正确的IP地址正则表达式
((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)
-
jsp与servlet联合处理
通过model1 或者说 model2 我们知道的mvc 的分层思想, 在model1 中jsp 通负责显示,有负责控制逻辑结构, 那么怎么做呢,看下面的请求过程. <?xml version= ...
-
Service Worker
Service Worker 随着前端快速发展,应用的性能已经变得至关重要,关于这一点大佬做了很多统计.你可以去看看. 如何降低一个页面的网络请求成本从而缩短页面加载资源的时间并降低用户可感知的延时是 ...
-
linux通过sendmail发送邮件
安装sendmail: [root@li676-235 ~]# yum install sendmail 安装好后执行. [root@li676-235 ~]# /etc/init.d/sendmai ...
-
appium+python自动化33-解锁九宫格(TouchAction)
TouchAction 1.源码可以在这个路径找到:Lib\site-packages\appium\webdriver\common\touch_action.py class TouchActio ...
-
Web会话安全分析工具ProxyStrike
Web会话安全分析工具ProxyStrike 在Web应用中,客户端发出一次请求,服务器响应一次.这构成一个完整的会话.通过分析请求和响应的数据,可以发现Web应用存在的漏洞.Kali Linux ...