0

I have installed tensorflow_hub package in python 3.6. The package can be imported correctly when I test it in python console. However, when I use it in a cgi-script an error occurs:

no module named tensorflow_hub 

Source Code

#!/usr/bin/python3.6
import sys
import cgitb
import cgi
t = ''
try: 
   import tensorflow_hub as tf
except Exception as e:
   t = str(e)
cgitb.enable()
sys.stdout.write("Content-Type: application/json")
sys.stdout.write("\n")
sys.stdout.write("\n")

result = dict()
result['data'] = t 

sys.stdout.write(json.dumps(result,indent=1)) 
sys.stdout.write("\n")

Could you explain me which is the problem? I tested other packages (e.g. tensorflow) but I hadn't any issue.

Edit

To install the package:

pip3 install tensorflow-hub

which pip3 
     /usr/bin/pip3

1 Answers1

0

To answer my question giving feedback to others with similar problem:

The tensorflow_hub was in the ~/.local/lib/python3.6/site-packages/ where the cgi hasn't got access.

To find the location:

pip3 show tensorflow_hub 

I observed that all the other packages where in /usr/local/lib/python3.6/dist-packages/

So, I moved the package from the first location to the second.

This helped me: Why can't python find some modules when I'm running CGI scripts from the web?