Forums

Scheduled Task Suddenly Not Working - /bin/bash: python: command not found

A few days ago, my scheduled tasks were running fine without any issues.

However, starting from yesterday, my scheduled tasks started failing with the following error message:

/bin/bash: python: command not found  
2025-02-25 11:01:09 -- Completed task, took 53.18 seconds, return code was 127.

/bin/bash: python: command not found  
2025-02-25 11:01:09 -- Completed task, took 53.18 seconds, return code was 127.

Commands I have tried:

I have attempted the following commands for my scheduled task:

/usr/local/bin/python3.10 /home/kai9527/mysite/daily_gen_disposal_3.py

python3.10 /home/kai9527/mysite/daily_gen_disposal_3.py

However, all of them resulted in the same error.

Troubleshooting Steps I Have Taken:

I have reviewed similar issues in these forum posts:

https://www.pythonanywhere.com/forums/topic/32138/

https://www.pythonanywhere.com/forums/topic/30597/

I have deleted .bashrc, .profile, and .bash_profile, then restarted my Bash console.

Unfortunately, the problem still persists.

Possible Cause? Recent Changes to My Environment

One change I made to my environment today was installing the ta and TA-Lib libraries.

As part of that process, I ran the following commands:

export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
echo 'export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH' >> ~/.bashrc
source ~/.bashrc


export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
echo 'export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH' >> ~/.bashrc
source ~/.bashrc

export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
echo 'export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH' >> ~/.bashrc
source ~/.bashrc

export CFLAGS="-I/usr/local/include"
export LDFLAGS="-L/usr/local/lib"
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
echo 'export CFLAGS="-I/usr/local/include"' >> ~/.bashrc
echo 'export LDFLAGS="-L/usr/local/lib"' >> ~/.bashrc
echo 'export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH' >> ~/.bashrc
source ~/.bashrc

export LD_LIBRARY_PATH=/usr/local/lib
echo 'export LD_LIBRARY_PATH=/usr/local/lib' > ~/.bashrc
source ~/.bashrc

I am not sure if this caused any issues, but as mentioned earlier, I deleted my .bashrc file and restarted my Bash console afterward.

I feel completely lost now... Please help!

oh by the way,

if i just directly run below command in the bash console, it can work.

/usr/local/bin/python3.10 /home/kai9527/mysite/daily_gen_disposal_3.py

python3.10 /home/kai9527/mysite/daily_gen_disposal_3.py

but it doesn't work by the scheduled task setting on the page.

Hmm, that's odd. What do you see when you start a new console and run "echo $PATH"?

@ nkahr

        Loading console...
        Preparing execution environment... OK
        Adding unicorns, cupcakes, awesomeness

and then clean all the screen and show:

kai9527@blue-liveconsole8:~$

My $PATH:

kai9527@blue-liveconsole8:~$ echo $PATH
/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

I found it strange the first time I saw it, so I asked GPT about it, and it told me that it doesn’t really affect my issue.

I remember making it more concise before, and I’ve also seen even weirder versions of it.

But this time, it showed up like this, which is what I see most often.

I hope you can find something—please save me lol !!!!

It's me again.

And good news, it fixed. I just delete the~/.bashrc, ~/.profile ,~/.bash_profile, agian and again...

and finaly, it worked!! ya, MAGIC. I am really very very happy.

so for someone who faces this problem in the future, just try below command first:

rm -f ~/.bashrc ~/.profile ~/.bash_profile

and if not working, try twice please.

It's strange that it didn't work the first time, but I'm glad it's fixed now!