0

I am trying to execute my python code from PHP application. But I am getting the below mentioned error when I try to execute from my PHP application. It works fine when running directly on the shell.

PHP: shell_exec( $scriptToCall . " 2>&1" );

Env:

  1. Python3
  2. PHP 7
  3. Ubuntu

Error:

ImportError: No module named 'httplib2'

I followed this link to - "ImportError: No module named httplib2" even after installation

also, pip list shows httplib2 installed.

Daljeet Singh
  • 704
  • 3
  • 7
  • 17

1 Answers1

1

most likely, httplib2 is not globally installed for all users, but installed for your user specifically. you say It works fine when running directly on the shell but don't specify which user, assuming you mean it works fine when i run it from MY OWN USER ACCOUNT, try running it from the same user account as your php script runs in, then you'll probably get the same error. in debian/ubuntu & co , it's by default sudo su www-data -s /bin/bash, in arch it's by default sudo su http -s /bin/bash to enter those accounts - and solution is to either globally install httplib2 or install it specifically for the php user account

hanshenrik
  • 19,904
  • 4
  • 43
  • 89