I need to launch a python script with no external dependencies from my rails app. I need to add the folder to PYTHONPATH and start the script. I tried this:
puts system(PYTHONPATH=../lib/python/ python ../reporter/src/reporter.py)
but the script does not work. It should create a specific file, but it doesn’t. I also tried:
puts system("PYTHONPATH=../lib/python/ | python ../reporter/src/reporter.py")
but I received the following error:
ImportError: No module named...."
It looks as though PYTHONPATH is not set in the second case. What am I doing wrong? How I can start the python script?
Have you tried
system("export PYTHONPATH=../lib/python/ && python ../reporter/src/reporter.py")You may also need to put the full path in and use Rails.root.to_s