I have a rails 4 app on AWS EC2 Ubuntu. It will call a python program using backticks:
pyresult = `python /path/to/abc.py`
The python programe works perfect on my local dev. But it failed on the production server, with no error. (pyresult is empty)
I've debugged for long time, and found a possible cause: $PYTHONPATH
On local, i have the follow in my .bashrc, as the python program asked to add:
export PYTHONPATH="$HOME/.local/lib/python2.7/site-packages/:$PYTHONPATH"
On server, i also added them in .bashrc on server. But run echo $PYTHONPATH
in my app gives me empty string.
Then I added explicitly in my rails app,
`export PYTHONPATH="$HOME/.local/lib/python2.7/site-packages/:$PYTHONPATH"`
pyresult = `python /path/to/abc.py`
but $PYTHONPATH is still empty. and calling python program still failed with no error.
Is it correct to guess the missing $PYTHONPATH caused the issue? if yes, how to solve the problem? Thanks for helping.(sorry i'm new to linux and not familiar with python)