Error in manage.py script when running cron job for django inside docker container The Next CEO of Stack OverflowDjango manage.py runserver invalid syntaxdjango-chronograph script wont run from cron job or manually due to permissions issueRun a Docker Image as a ContainerHow to enter in a Docker container already running with a new TTYFrom inside of a Docker container, how do I connect to the localhost of the machine?How to run a cron job inside a docker container?rake command not running from cron job but works otherwiseCron in Docker container parallel with DjangoRunning a python script as a cron job in FreeBSDNot able to run cron jobs with djangoPermission denied on mkdir inside of a django Docker container when running collectstatic
Can you replace a racial trait cantrip when leveling up?
In the bitcoin scripting language, how can I access other outputs of the transaction? Or how else can I limit how the coins may be spent?
Example of a Mathematician/Physicist whose Other Publications during their PhD eclipsed their PhD Thesis
What can we do to stop prior company from asking us questions?
If Nick Fury and Coulson already knew about aliens (Kree and Skrull) why did they wait until Thor's appearance to start making weapons?
What is the purpose of the Evocation wizard's Potent Cantrip feature?
What does convergence in distribution "in the Gromov–Hausdorff" sense mean?
Make solar eclipses exceedingly rare, but still have new moons
Return the Closest Prime Number
Why is the US ranked as #45 in Press Freedom ratings, despite its extremely permissive free speech laws?
Why does the UK parliament need a vote on the political declaration?
Why do variable in an inner function return nan when there is the same variable name at the inner function declared after log
What does "Its cash flow is deeply negative" mean?
Is it ever safe to open a suspicious html file (e.g. email attachment)?
How do I go from 300 unfinished/half written blog posts, to published posts?
Would this house-rule that treats advantage as a +1 to the roll instead (and disadvantage as -1) and allows them to stack be balanced?
Can we say or write : "No, it'sn't"?
Is it my responsibility to learn a new technology in my own time my employer wants to implement?
How does the Z80 determine which peripheral sent an interrupt?
Why do remote companies require working in the US?
Is 'diverse range' a pleonastic phrase?
Is there a difference between "Fahrstuhl" and "Aufzug"
If the heap is initialized for security, then why is the stack uninitialized?
Should I tutor a student who I know has cheated on their homework?
Error in manage.py script when running cron job for django inside docker container
The Next CEO of Stack OverflowDjango manage.py runserver invalid syntaxdjango-chronograph script wont run from cron job or manually due to permissions issueRun a Docker Image as a ContainerHow to enter in a Docker container already running with a new TTYFrom inside of a Docker container, how do I connect to the localhost of the machine?How to run a cron job inside a docker container?rake command not running from cron job but works otherwiseCron in Docker container parallel with DjangoRunning a python script as a cron job in FreeBSDNot able to run cron jobs with djangoPermission denied on mkdir inside of a django Docker container when running collectstatic
I have a docker container runnning a django application that is also running a cron job inside it. The managed command keeps failing due to this error:
Line 14 in manage.py
line 14
) from exc
^
SyntaxError: invalid syntax
My cron job looks like this:
0 1 * * 1-5 python manage.py myCommand
I tried changing it to this to see if that would do the trick:
0 1 * * 1-5 /usr/local/bin/python /absolute/path/to/project/manage.py myCommand
python django docker cron
|
show 2 more comments
I have a docker container runnning a django application that is also running a cron job inside it. The managed command keeps failing due to this error:
Line 14 in manage.py
line 14
) from exc
^
SyntaxError: invalid syntax
My cron job looks like this:
0 1 * * 1-5 python manage.py myCommand
I tried changing it to this to see if that would do the trick:
0 1 * * 1-5 /usr/local/bin/python /absolute/path/to/project/manage.py myCommand
python django docker cron
It seems to me installation not getting aware of Django?
– webbyfox
Mar 8 at 14:37
1
connected: stackoverflow.com/questions/47880626/…
– Dany
Mar 8 at 14:38
I manually ran the command (stepping into the container interactively) and it ran fine. Django is installed in the container. I just don't understand why it wouldn't run under cron.
– Jasonca1
Mar 8 at 14:39
1
The invalid syntax is from Python 2. You are using a version of Django that requires Python 3. Change your cron command so that it uses Python 3. If you use a virtual environment, then use the Python from the virtual environment.
– Alasdair
Mar 8 at 14:59
1
It looks like your container has Python 2 as well, Python 3.5 wouldn't give the syntax error.
– Alasdair
Mar 8 at 15:04
|
show 2 more comments
I have a docker container runnning a django application that is also running a cron job inside it. The managed command keeps failing due to this error:
Line 14 in manage.py
line 14
) from exc
^
SyntaxError: invalid syntax
My cron job looks like this:
0 1 * * 1-5 python manage.py myCommand
I tried changing it to this to see if that would do the trick:
0 1 * * 1-5 /usr/local/bin/python /absolute/path/to/project/manage.py myCommand
python django docker cron
I have a docker container runnning a django application that is also running a cron job inside it. The managed command keeps failing due to this error:
Line 14 in manage.py
line 14
) from exc
^
SyntaxError: invalid syntax
My cron job looks like this:
0 1 * * 1-5 python manage.py myCommand
I tried changing it to this to see if that would do the trick:
0 1 * * 1-5 /usr/local/bin/python /absolute/path/to/project/manage.py myCommand
python django docker cron
python django docker cron
asked Mar 8 at 14:36
Jasonca1Jasonca1
335415
335415
It seems to me installation not getting aware of Django?
– webbyfox
Mar 8 at 14:37
1
connected: stackoverflow.com/questions/47880626/…
– Dany
Mar 8 at 14:38
I manually ran the command (stepping into the container interactively) and it ran fine. Django is installed in the container. I just don't understand why it wouldn't run under cron.
– Jasonca1
Mar 8 at 14:39
1
The invalid syntax is from Python 2. You are using a version of Django that requires Python 3. Change your cron command so that it uses Python 3. If you use a virtual environment, then use the Python from the virtual environment.
– Alasdair
Mar 8 at 14:59
1
It looks like your container has Python 2 as well, Python 3.5 wouldn't give the syntax error.
– Alasdair
Mar 8 at 15:04
|
show 2 more comments
It seems to me installation not getting aware of Django?
– webbyfox
Mar 8 at 14:37
1
connected: stackoverflow.com/questions/47880626/…
– Dany
Mar 8 at 14:38
I manually ran the command (stepping into the container interactively) and it ran fine. Django is installed in the container. I just don't understand why it wouldn't run under cron.
– Jasonca1
Mar 8 at 14:39
1
The invalid syntax is from Python 2. You are using a version of Django that requires Python 3. Change your cron command so that it uses Python 3. If you use a virtual environment, then use the Python from the virtual environment.
– Alasdair
Mar 8 at 14:59
1
It looks like your container has Python 2 as well, Python 3.5 wouldn't give the syntax error.
– Alasdair
Mar 8 at 15:04
It seems to me installation not getting aware of Django?
– webbyfox
Mar 8 at 14:37
It seems to me installation not getting aware of Django?
– webbyfox
Mar 8 at 14:37
1
1
connected: stackoverflow.com/questions/47880626/…
– Dany
Mar 8 at 14:38
connected: stackoverflow.com/questions/47880626/…
– Dany
Mar 8 at 14:38
I manually ran the command (stepping into the container interactively) and it ran fine. Django is installed in the container. I just don't understand why it wouldn't run under cron.
– Jasonca1
Mar 8 at 14:39
I manually ran the command (stepping into the container interactively) and it ran fine. Django is installed in the container. I just don't understand why it wouldn't run under cron.
– Jasonca1
Mar 8 at 14:39
1
1
The invalid syntax is from Python 2. You are using a version of Django that requires Python 3. Change your cron command so that it uses Python 3. If you use a virtual environment, then use the Python from the virtual environment.
– Alasdair
Mar 8 at 14:59
The invalid syntax is from Python 2. You are using a version of Django that requires Python 3. Change your cron command so that it uses Python 3. If you use a virtual environment, then use the Python from the virtual environment.
– Alasdair
Mar 8 at 14:59
1
1
It looks like your container has Python 2 as well, Python 3.5 wouldn't give the syntax error.
– Alasdair
Mar 8 at 15:04
It looks like your container has Python 2 as well, Python 3.5 wouldn't give the syntax error.
– Alasdair
Mar 8 at 15:04
|
show 2 more comments
1 Answer
1
active
oldest
votes
This is a typical error you get when using a wrong Python version. Following your comment under the question:
The docker container is using python 3.5. When I run python -V, I get
Python 3.5.6
You can see that your user's $PATH
points to Python 3.5.6 when using the shell session you open. There is one thing about cron jobs that often leaves people stuck with problems: cron opens a different shell and doesn't have access to your $PATH
. So in your case it points to Python 2.x.
There are many ways to overcome this. Probably the easiest one is to check where your Python 3 is located by running
$ which python3
and using the path from the output in your cron command. For example, for my system it would be:
0 1 * * 1-5 /usr/bin/python3 manage.py myCommand
Gotcha. Thank you very much for pointing that out. I appreciate it a lot.
– Jasonca1
Mar 8 at 16:31
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55065386%2ferror-in-manage-py-script-when-running-cron-job-for-django-inside-docker-contain%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
This is a typical error you get when using a wrong Python version. Following your comment under the question:
The docker container is using python 3.5. When I run python -V, I get
Python 3.5.6
You can see that your user's $PATH
points to Python 3.5.6 when using the shell session you open. There is one thing about cron jobs that often leaves people stuck with problems: cron opens a different shell and doesn't have access to your $PATH
. So in your case it points to Python 2.x.
There are many ways to overcome this. Probably the easiest one is to check where your Python 3 is located by running
$ which python3
and using the path from the output in your cron command. For example, for my system it would be:
0 1 * * 1-5 /usr/bin/python3 manage.py myCommand
Gotcha. Thank you very much for pointing that out. I appreciate it a lot.
– Jasonca1
Mar 8 at 16:31
add a comment |
This is a typical error you get when using a wrong Python version. Following your comment under the question:
The docker container is using python 3.5. When I run python -V, I get
Python 3.5.6
You can see that your user's $PATH
points to Python 3.5.6 when using the shell session you open. There is one thing about cron jobs that often leaves people stuck with problems: cron opens a different shell and doesn't have access to your $PATH
. So in your case it points to Python 2.x.
There are many ways to overcome this. Probably the easiest one is to check where your Python 3 is located by running
$ which python3
and using the path from the output in your cron command. For example, for my system it would be:
0 1 * * 1-5 /usr/bin/python3 manage.py myCommand
Gotcha. Thank you very much for pointing that out. I appreciate it a lot.
– Jasonca1
Mar 8 at 16:31
add a comment |
This is a typical error you get when using a wrong Python version. Following your comment under the question:
The docker container is using python 3.5. When I run python -V, I get
Python 3.5.6
You can see that your user's $PATH
points to Python 3.5.6 when using the shell session you open. There is one thing about cron jobs that often leaves people stuck with problems: cron opens a different shell and doesn't have access to your $PATH
. So in your case it points to Python 2.x.
There are many ways to overcome this. Probably the easiest one is to check where your Python 3 is located by running
$ which python3
and using the path from the output in your cron command. For example, for my system it would be:
0 1 * * 1-5 /usr/bin/python3 manage.py myCommand
This is a typical error you get when using a wrong Python version. Following your comment under the question:
The docker container is using python 3.5. When I run python -V, I get
Python 3.5.6
You can see that your user's $PATH
points to Python 3.5.6 when using the shell session you open. There is one thing about cron jobs that often leaves people stuck with problems: cron opens a different shell and doesn't have access to your $PATH
. So in your case it points to Python 2.x.
There are many ways to overcome this. Probably the easiest one is to check where your Python 3 is located by running
$ which python3
and using the path from the output in your cron command. For example, for my system it would be:
0 1 * * 1-5 /usr/bin/python3 manage.py myCommand
answered Mar 8 at 16:22
arudzinskaarudzinska
1,4641721
1,4641721
Gotcha. Thank you very much for pointing that out. I appreciate it a lot.
– Jasonca1
Mar 8 at 16:31
add a comment |
Gotcha. Thank you very much for pointing that out. I appreciate it a lot.
– Jasonca1
Mar 8 at 16:31
Gotcha. Thank you very much for pointing that out. I appreciate it a lot.
– Jasonca1
Mar 8 at 16:31
Gotcha. Thank you very much for pointing that out. I appreciate it a lot.
– Jasonca1
Mar 8 at 16:31
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55065386%2ferror-in-manage-py-script-when-running-cron-job-for-django-inside-docker-contain%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
It seems to me installation not getting aware of Django?
– webbyfox
Mar 8 at 14:37
1
connected: stackoverflow.com/questions/47880626/…
– Dany
Mar 8 at 14:38
I manually ran the command (stepping into the container interactively) and it ran fine. Django is installed in the container. I just don't understand why it wouldn't run under cron.
– Jasonca1
Mar 8 at 14:39
1
The invalid syntax is from Python 2. You are using a version of Django that requires Python 3. Change your cron command so that it uses Python 3. If you use a virtual environment, then use the Python from the virtual environment.
– Alasdair
Mar 8 at 14:59
1
It looks like your container has Python 2 as well, Python 3.5 wouldn't give the syntax error.
– Alasdair
Mar 8 at 15:04