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










0















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









share|improve this question






















  • 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















0















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









share|improve this question






















  • 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













0












0








0








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









share|improve this question














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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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

















  • 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












1 Answer
1






active

oldest

votes


















2














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





share|improve this answer























  • Gotcha. Thank you very much for pointing that out. I appreciate it a lot.

    – Jasonca1
    Mar 8 at 16:31











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%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









2














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





share|improve this answer























  • Gotcha. Thank you very much for pointing that out. I appreciate it a lot.

    – Jasonca1
    Mar 8 at 16:31















2














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





share|improve this answer























  • Gotcha. Thank you very much for pointing that out. I appreciate it a lot.

    – Jasonca1
    Mar 8 at 16:31













2












2








2







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





share|improve this answer













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






share|improve this answer












share|improve this answer



share|improve this answer










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

















  • 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



















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%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





















































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

Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme

Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived