Django on Debian 9 - ImportError: No module named 'PROJECT.settings.py'












0














I'm trying to deploy my Django app on Google compute engine Debian VM instance, I have installed the Python(3.6) and setup virtual environment then clone my Django application which is working perfectly well on the local system.
When I try to run python manage.py migrate command it returns an error as:




ImportError: No module named 'Fetchors.settings.py'; 'Fetchors.settings' is not a package




Here's my Fetchors/wsgi.py:



import os
from django.core.wsgi import get_wsgi_application
from whitenoise.django import DjangoWhiteNoise
path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
print(path)
if path not in sys.path:
sys.path.append(path)
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "Fetchors.settings")
application = get_wsgi_application()
application = DjangoWhiteNoise(application)



Update: my directory struture is:




|-Fetchors
|--Fetchors
|--settings.py
|--manage.py


here's my manage.py:



#!/usr/bin/env python
import os
import sys

if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "Fetchors.settings.py")
try:
from django.core.management import execute_from_command_line
except ImportError:
# The above import may fail for some other reason. Ensure that the
# issue is really that Django is missing to avoid masking other
# exceptions on Python 2.
try:
import django
except ImportError:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
)
raise
execute_from_command_line(sys.argv)


What can be wrong here?



Thanks in advance!










share|improve this question
























  • Does your Fetchors have a settings.py file?
    – Willem Van Onsem
    Dec 28 '18 at 11:12










  • Yes, it has, Project name is Fetchors then the main app name is also Fetchors .So, I have Fetchors/Fetchors/settings.py
    – Abdul Rehman
    Dec 28 '18 at 11:14










  • Have you added the line Fetchors.settings.py somewhere?
    – saad
    Dec 28 '18 at 11:36












  • it's only mentioned as Fetchors.settings in wsgi.py
    – Abdul Rehman
    Dec 28 '18 at 11:43
















0














I'm trying to deploy my Django app on Google compute engine Debian VM instance, I have installed the Python(3.6) and setup virtual environment then clone my Django application which is working perfectly well on the local system.
When I try to run python manage.py migrate command it returns an error as:




ImportError: No module named 'Fetchors.settings.py'; 'Fetchors.settings' is not a package




Here's my Fetchors/wsgi.py:



import os
from django.core.wsgi import get_wsgi_application
from whitenoise.django import DjangoWhiteNoise
path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
print(path)
if path not in sys.path:
sys.path.append(path)
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "Fetchors.settings")
application = get_wsgi_application()
application = DjangoWhiteNoise(application)



Update: my directory struture is:




|-Fetchors
|--Fetchors
|--settings.py
|--manage.py


here's my manage.py:



#!/usr/bin/env python
import os
import sys

if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "Fetchors.settings.py")
try:
from django.core.management import execute_from_command_line
except ImportError:
# The above import may fail for some other reason. Ensure that the
# issue is really that Django is missing to avoid masking other
# exceptions on Python 2.
try:
import django
except ImportError:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
)
raise
execute_from_command_line(sys.argv)


What can be wrong here?



Thanks in advance!










share|improve this question
























  • Does your Fetchors have a settings.py file?
    – Willem Van Onsem
    Dec 28 '18 at 11:12










  • Yes, it has, Project name is Fetchors then the main app name is also Fetchors .So, I have Fetchors/Fetchors/settings.py
    – Abdul Rehman
    Dec 28 '18 at 11:14










  • Have you added the line Fetchors.settings.py somewhere?
    – saad
    Dec 28 '18 at 11:36












  • it's only mentioned as Fetchors.settings in wsgi.py
    – Abdul Rehman
    Dec 28 '18 at 11:43














0












0








0







I'm trying to deploy my Django app on Google compute engine Debian VM instance, I have installed the Python(3.6) and setup virtual environment then clone my Django application which is working perfectly well on the local system.
When I try to run python manage.py migrate command it returns an error as:




ImportError: No module named 'Fetchors.settings.py'; 'Fetchors.settings' is not a package




Here's my Fetchors/wsgi.py:



import os
from django.core.wsgi import get_wsgi_application
from whitenoise.django import DjangoWhiteNoise
path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
print(path)
if path not in sys.path:
sys.path.append(path)
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "Fetchors.settings")
application = get_wsgi_application()
application = DjangoWhiteNoise(application)



Update: my directory struture is:




|-Fetchors
|--Fetchors
|--settings.py
|--manage.py


here's my manage.py:



#!/usr/bin/env python
import os
import sys

if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "Fetchors.settings.py")
try:
from django.core.management import execute_from_command_line
except ImportError:
# The above import may fail for some other reason. Ensure that the
# issue is really that Django is missing to avoid masking other
# exceptions on Python 2.
try:
import django
except ImportError:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
)
raise
execute_from_command_line(sys.argv)


What can be wrong here?



Thanks in advance!










share|improve this question















I'm trying to deploy my Django app on Google compute engine Debian VM instance, I have installed the Python(3.6) and setup virtual environment then clone my Django application which is working perfectly well on the local system.
When I try to run python manage.py migrate command it returns an error as:




ImportError: No module named 'Fetchors.settings.py'; 'Fetchors.settings' is not a package




Here's my Fetchors/wsgi.py:



import os
from django.core.wsgi import get_wsgi_application
from whitenoise.django import DjangoWhiteNoise
path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
print(path)
if path not in sys.path:
sys.path.append(path)
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "Fetchors.settings")
application = get_wsgi_application()
application = DjangoWhiteNoise(application)



Update: my directory struture is:




|-Fetchors
|--Fetchors
|--settings.py
|--manage.py


here's my manage.py:



#!/usr/bin/env python
import os
import sys

if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "Fetchors.settings.py")
try:
from django.core.management import execute_from_command_line
except ImportError:
# The above import may fail for some other reason. Ensure that the
# issue is really that Django is missing to avoid masking other
# exceptions on Python 2.
try:
import django
except ImportError:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
)
raise
execute_from_command_line(sys.argv)


What can be wrong here?



Thanks in advance!







python django debian django-migrations






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 29 '18 at 7:11







Abdul Rehman

















asked Dec 28 '18 at 11:09









Abdul RehmanAbdul Rehman

943323




943323












  • Does your Fetchors have a settings.py file?
    – Willem Van Onsem
    Dec 28 '18 at 11:12










  • Yes, it has, Project name is Fetchors then the main app name is also Fetchors .So, I have Fetchors/Fetchors/settings.py
    – Abdul Rehman
    Dec 28 '18 at 11:14










  • Have you added the line Fetchors.settings.py somewhere?
    – saad
    Dec 28 '18 at 11:36












  • it's only mentioned as Fetchors.settings in wsgi.py
    – Abdul Rehman
    Dec 28 '18 at 11:43


















  • Does your Fetchors have a settings.py file?
    – Willem Van Onsem
    Dec 28 '18 at 11:12










  • Yes, it has, Project name is Fetchors then the main app name is also Fetchors .So, I have Fetchors/Fetchors/settings.py
    – Abdul Rehman
    Dec 28 '18 at 11:14










  • Have you added the line Fetchors.settings.py somewhere?
    – saad
    Dec 28 '18 at 11:36












  • it's only mentioned as Fetchors.settings in wsgi.py
    – Abdul Rehman
    Dec 28 '18 at 11:43
















Does your Fetchors have a settings.py file?
– Willem Van Onsem
Dec 28 '18 at 11:12




Does your Fetchors have a settings.py file?
– Willem Van Onsem
Dec 28 '18 at 11:12












Yes, it has, Project name is Fetchors then the main app name is also Fetchors .So, I have Fetchors/Fetchors/settings.py
– Abdul Rehman
Dec 28 '18 at 11:14




Yes, it has, Project name is Fetchors then the main app name is also Fetchors .So, I have Fetchors/Fetchors/settings.py
– Abdul Rehman
Dec 28 '18 at 11:14












Have you added the line Fetchors.settings.py somewhere?
– saad
Dec 28 '18 at 11:36






Have you added the line Fetchors.settings.py somewhere?
– saad
Dec 28 '18 at 11:36














it's only mentioned as Fetchors.settings in wsgi.py
– Abdul Rehman
Dec 28 '18 at 11:43




it's only mentioned as Fetchors.settings in wsgi.py
– Abdul Rehman
Dec 28 '18 at 11:43












1 Answer
1






active

oldest

votes


















0














Add __init__.py file in your innermost Fetchors folder if it's not available.
So your directory structure should look like below:



|-Fetchors
|--Fetchors
|--__init__.py
|--settings.py
|--manage.py


This lets the python know to treat the Fetchors is a package. __init__.py can be empty file. And it should be already present in the folder.






share|improve this answer





















  • there's already a __init__.py file exists.
    – Abdul Rehman
    Dec 28 '18 at 15:30












  • Can you post the output for the path variable being set in wsgi.py? Most probably that will cause the issue if the project folder is not part of path.
    – SwapnilBhate
    Jan 2 at 4:16











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53957579%2fdjango-on-debian-9-importerror-no-module-named-project-settings-py%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Add __init__.py file in your innermost Fetchors folder if it's not available.
So your directory structure should look like below:



|-Fetchors
|--Fetchors
|--__init__.py
|--settings.py
|--manage.py


This lets the python know to treat the Fetchors is a package. __init__.py can be empty file. And it should be already present in the folder.






share|improve this answer





















  • there's already a __init__.py file exists.
    – Abdul Rehman
    Dec 28 '18 at 15:30












  • Can you post the output for the path variable being set in wsgi.py? Most probably that will cause the issue if the project folder is not part of path.
    – SwapnilBhate
    Jan 2 at 4:16
















0














Add __init__.py file in your innermost Fetchors folder if it's not available.
So your directory structure should look like below:



|-Fetchors
|--Fetchors
|--__init__.py
|--settings.py
|--manage.py


This lets the python know to treat the Fetchors is a package. __init__.py can be empty file. And it should be already present in the folder.






share|improve this answer





















  • there's already a __init__.py file exists.
    – Abdul Rehman
    Dec 28 '18 at 15:30












  • Can you post the output for the path variable being set in wsgi.py? Most probably that will cause the issue if the project folder is not part of path.
    – SwapnilBhate
    Jan 2 at 4:16














0












0








0






Add __init__.py file in your innermost Fetchors folder if it's not available.
So your directory structure should look like below:



|-Fetchors
|--Fetchors
|--__init__.py
|--settings.py
|--manage.py


This lets the python know to treat the Fetchors is a package. __init__.py can be empty file. And it should be already present in the folder.






share|improve this answer












Add __init__.py file in your innermost Fetchors folder if it's not available.
So your directory structure should look like below:



|-Fetchors
|--Fetchors
|--__init__.py
|--settings.py
|--manage.py


This lets the python know to treat the Fetchors is a package. __init__.py can be empty file. And it should be already present in the folder.







share|improve this answer












share|improve this answer



share|improve this answer










answered Dec 28 '18 at 12:30









SwapnilBhateSwapnilBhate

1012




1012












  • there's already a __init__.py file exists.
    – Abdul Rehman
    Dec 28 '18 at 15:30












  • Can you post the output for the path variable being set in wsgi.py? Most probably that will cause the issue if the project folder is not part of path.
    – SwapnilBhate
    Jan 2 at 4:16


















  • there's already a __init__.py file exists.
    – Abdul Rehman
    Dec 28 '18 at 15:30












  • Can you post the output for the path variable being set in wsgi.py? Most probably that will cause the issue if the project folder is not part of path.
    – SwapnilBhate
    Jan 2 at 4:16
















there's already a __init__.py file exists.
– Abdul Rehman
Dec 28 '18 at 15:30






there's already a __init__.py file exists.
– Abdul Rehman
Dec 28 '18 at 15:30














Can you post the output for the path variable being set in wsgi.py? Most probably that will cause the issue if the project folder is not part of path.
– SwapnilBhate
Jan 2 at 4:16




Can you post the output for the path variable being set in wsgi.py? Most probably that will cause the issue if the project folder is not part of path.
– SwapnilBhate
Jan 2 at 4:16


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53957579%2fdjango-on-debian-9-importerror-no-module-named-project-settings-py%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Monofisismo

Angular Downloading a file using contenturl with Basic Authentication

Olmecas