Running python file within a shell script : module not found error

Viewed 532

I'm beginner to both bash and python.

I'm working in Ubuntu env.

to be short, I've created a shell script 'format_data.sh' that runs python file 'proc_ko.py' within it.

#!/bin/bash
...
python path/to/python/file/proc_ko.py
...

And the python file 'proc_ko.py' imports a module called khaiii

from khaiii import KhaiiiApi
api = KhaiiiApi()
...

But when I try to execute 'format_data.sh', I get this import error from python file.

Traceback (most recent call last):
File "media/sf_projet/pe/pe/PROGRAMME/SCRIPTS/proc_ko.py", line 5, in
from khaiii import KhaiiiApi
ImportError: No module named khaiii

which doesn't occur when I execute python file independently.

Python file 'proc_ko.py' itself doesn't have any error and 'khaiii' is well installed.

so I don't understand why import error occurs only through the shell script.

If u need more details to figure out, I'll be happy to provide. Thanks in advance for help.

0 Answers
Related