0

I am trying to run a bash file from matlab that exectes a python file. If I simply run the bash from the terminal using:

source test_bash.sh

It runs fine. However, when I run from matlab:

system('source test_bash.sh')

I get the following error:

ImportError: No module named unidecode

I don't understand the difference between running the same bash file from the terminal and from Matlab (using system()).

5
  • Can you share the python gist Commented Apr 9, 2018 at 8:49
  • its a python script that does some text editing and refomatting and than run a force-alignment script that uses htk. However, it seems to stack at the second line of the script when trying to import unidecode Commented Apr 9, 2018 at 8:54
  • How are you starting matlab? Is it from an environment that has all the variables/paths/etc defined that are required to run the python script? Commented Apr 10, 2018 at 2:00
  • how do I make sure that they have the same environment? Commented Apr 10, 2018 at 2:12
  • @user552231 Start matlab from a shell that has everything needed by the python script defined. Commented Apr 10, 2018 at 13:07

1 Answer 1

2

The path you are running the matlab script seems unable to find the python packages(in our case unidecode package)

Try to run the script from the path exactly, the shell runs from

Incase if you want to add an environment variable in matlab to achieve the above use setenv(name,value) method & try to run the matlab script again

Sign up to request clarification or add additional context in comments.

2 Comments

Lets do one thing, before trying to run the shell script lets run the python script from matlab. Can you run system('/path/to/my/venv/bin/python myscript.py')test it works or not.
It returned the same error (dont find unidecode package)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.