Skip to main content
Stack Overflow
  1. About
  2. For Teams

Return to Question

added 18 characters in body
Source Link

I want to execute Python script from PHP file using apache2 on my macos. I am able to execute simple python script like:

From PHP:

$result = shell_exec("python /Library/..../example.py '$name' ‘$email’ ");
var_dump($result);

To Python

import sys
x = sys.argv[1]
y = sys.argv[2]
print("name: " + x + "<br>")
print("email: " + y + "<br>")

and the output is:

enter image description here

But when I try to import packages like :

import openpyxl
import numpy as np
import matplotlib.pyplot as plt

I get:

enter image description here

My question is, does anyone knows:

1 – How can I make those (and any other) packages work?

2 – shell_exec is currently executing python2. How can I add python3?( if I write python3 instead of python won’t work)

I want to execute Python script from PHP file using apache2 on my macos. I am able to execute simple python script like:

From PHP:

$result = shell_exec("python /Library/..../example.py '$name' ‘$email’ ");
var_dump($result);

To Python

import sys
x = sys.argv[1]
y = sys.argv[2]
print("name: " + x + "<br>")
print("email: " + y + "<br>")

and the output is:enter image description here

But when I try to import packages like :

import openpyxl
import numpy as np
import matplotlib.pyplot as plt

I get:enter image description here

My question is, does anyone knows:1 – How can I make those (and any other) packages work?2 – shell_exec is currently executing python2. How can I add python3?( if I write python3 instead of python won’t work)

I want to execute Python script from PHP file using apache2 on my macos. I am able to execute simple python script like:

From PHP:

$result = shell_exec("python /Library/..../example.py '$name' ‘$email’ ");
var_dump($result);

To Python

import sys
x = sys.argv[1]
y = sys.argv[2]
print("name: " + x + "<br>")
print("email: " + y + "<br>")

and the output is:

enter image description here

But when I try to import packages like :

import openpyxl
import numpy as np
import matplotlib.pyplot as plt

I get:

enter image description here

My question is, does anyone knows:

1 – How can I make those (and any other) packages work?

2 – shell_exec is currently executing python2. How can I add python3?( if I write python3 instead of python won’t work)

Source Link

Can't execute python script from PHP (apache2)

I want to execute Python script from PHP file using apache2 on my macos. I am able to execute simple python script like:

From PHP:

$result = shell_exec("python /Library/..../example.py '$name' ‘$email’ ");
var_dump($result);

To Python

import sys
x = sys.argv[1]
y = sys.argv[2]
print("name: " + x + "<br>")
print("email: " + y + "<br>")

and the output is: enter image description here

But when I try to import packages like :

import openpyxl
import numpy as np
import matplotlib.pyplot as plt

I get: enter image description here

My question is, does anyone knows: 1 – How can I make those (and any other) packages work? 2 – shell_exec is currently executing python2. How can I add python3?( if I write python3 instead of python won’t work)

default

AltStyle によって変換されたページ (->オリジナル) /