I am using PyCharm IDE and when I run any file.py
I get this error:
I am using PyCharm IDE and when I run any file.py I get this error:
..raise ImportError(“Settings cannot be imported, because environment variable %s is undefined.” % ENVIRONMENT_VARIABLE) ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined.
..raise ImportError(“Cannot import settings because environment variable %s is not defined.” %ENVIRONMENT_VARIABLE) ImportError: Cannot import settings because environment variable is not defined DJANGO_SETTINGS_MODULE.
How to configure DJANGO_SETTINGS_MODULE
environment variable in PyCharm?
How to configure the DJANGO_SETTINGS_MODULE environment variable in PyCharm?
4 solutions
#1
18
I had the same problem. The settings of my django support was empty:
I have the same problem. My django supported settings are empty:
#2
9
I had the same problem as well, and the fix in IntelliJ IDEA is not obvious (especially since there is no notification with a “fix-it” link for this problem).
I had the same problem and the fix in IntelliJ IDEA was not obvious (especially since there is no “fix-it” link for this issue notify).
You’ll find you need to set Settings to your Django project’s settings.py file in Project Structure > Modules > [your Django project’s name] > Django.
You will find that you need to set the settings to your Django project’s settings.py file in Project Structure > Modules > [your Django project name] > Django.
#3
8
You can go to the tool bar which shows a dropdown and select your project ->edit configuration. There in the Environment variable area enter DJANGO_SETTINGS_MODULE mysite.settings and save .
You can go to the toolbar that shows the drop-down list and select Project -> Edit Configuration. Enter DJANGO_SETTINGS_MODULE mysite.settings in the Environment variable area and save.
#4
7
“Standalone Django scripts”
“Stand-alone Django script”