0

i'm kind of new on php and i have a problem on running python program in php file.

i'll show you my codes first.

<?php 
putenv('PYTHONPATH=/home/bow/.local/lib/python3.6/site-packages:');
$command = '/usr/bin/python3 /home/bow/PycharmProjects/deep_pose/test.py 2>&1';
$output = shell_exec($command);
?>

test.py

import sys
import numpy as np
#print(sys.path)    

list1 = [1,2,3,4]
a = np.array(list1)
print(a.shape)

b = np.array([[1,2,3],[4,5,6]])
print(b.shape)
print(b[0,0])

and it shows this error

Traceback (most recent call alist):File "~", line 2, in import numpy as np ModuleNotFoundError:No module named 'numpy'

i tried both sys.path.append & sys.path.insert in python instead of putenv, but it didn't work neither.

there was no problem when i run the python in terminal. i've seen and tried almost everything i could find, so please help me to solve this problem. Is there something for this?

devh
  • 1
  • 1
    https://stackoverflow.com/questions/7818811/import-error-no-module-named-numpy – Felippe Duarte Feb 21 '20 at 13:21
  • Does this answer your question? [Import Error: No module named numpy](https://stackoverflow.com/questions/7818811/import-error-no-module-named-numpy) – Miamy Feb 21 '20 at 13:55

0 Answers0