I'm using pyenv 2.3.22 on a Raspberry Pi, with ./profile entry:
export PYENV_ROOT="$HOME/.pyenv"
command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
Since I want to execute a Python program whenever the system starts, I added a @reboot entry via crontab -e.
Everything works fine, but I get different Python runtime environments and I cannot find the reason and fix for that:
bash terminal: Python 3.11.4
crontab start: Python 3.9.2
My program is not running properly because of the differences when called by crontab.
I encapsulated the program start in a bash script to get informations for the crontab @reboot case. Everything (UserID, PATH, etc.) looks good, except the different Python versions.
I have a similar environment on annother Raspberry Pi. There it's even worse:
**bash terminal:**
python --version. -> 3.11.4
python3 --version. -> 3.11.4
**crontab start:**
python --version -> 2.7.16
python3 --version. -> 3.7.3
I would expect an identical Python runtime environment for both program start methods.
<added 2023-10-07> I would also be able to run the program from a remote host via ssh. It shows also a different environment that the local bash-terminal execution.
However there must be must be some differences, but I cannot find them. I would really appreciate any ideas or hints where to look.
Instead of starting the Python program directly, I wrote a shell script wrapper around it. This gave me insight at run time and let me execute and check the proper preparations settings (even on my Mac).
And last but not least: A big thanks to Philippe and his comment. It lead me to solving the problem.