Quantcast
Channel: Active questions tagged python - Webmasters Stack Exchange
Viewing all articles
Browse latest Browse all 46

Running Python script via PHP exec() on shared hosting

$
0
0

I have a PHP script that launches a Python script. It works fine when I am testing locally, but not on the shared hosting server. I've made the Python script, as well as the Python program files, executable for everyone using chmod. They are all installed under my /home/joeschome directory. I can run the Python script through an SSH terminal. What other troubleshooting steps can I take so that any web user can launch the Python script, via PHP?

EDIT

exec() does work with a hello.sh script. Python has all of the permissions through chmod. I even set up a virtual environment for python in the web root folder. I am getting exit status 127 for my python script. I can run it from the terminal just fine.

EDIT

It looks like the server is having a hard time finding the interpreter path when I just run it with

./hello.py

If I run it with an alias, it cooperates better.

python hello.py

If I want it to work with 3rd party modules, it prefers that I use the full path for the interpreter. I'll just use that for now.

/home/joe/public_html/my_venv/bin/python3.8 hello.py


Viewing all articles
Browse latest Browse all 46

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>