The path to the Python executable on Heroku… here is a solution to the problem.
The path to the Python executable on Heroku
I have an application that uses a python shell module from Node.js to run python scripts. Works for my local and everything. However, when I run it on heroku, the path to the python executable throws an error where Python can’t be found.
I used type -a
python on the Heroku console, which returned /usr/bin/python and /app/.heroku
/python/bin/python
When I use any of these paths in the python shell options[pythonPath]
object key, it doesn’t work and throws the error Error: spawn/app/.heroku/python/bin/python ENOENT
I’m running Python and Nodejs BuildPack.
Solution
Create a configuration variable under the heroku application settings, for example
PYTHONPATH = /usr/bin/python
Then use it in your app
process.env.PYTHONPATH
Where you need it
Hope that helps