I
I
Isagadji2017-05-14 10:19:46
linux
Isagadji, 2017-05-14 10:19:46

I execute python script from php using shell_exec function, it gives error 'ascii' codec can't encode?

Good afternoon!
I execute the command to run a python script from PHP (shell_exec, exec, system) the script gives an error: 'ascii' codec can't encode characters in position 0-8: ordinal not in range(128).
I execute the same command from the console - everything works. What can be a jamb?
Debian, Python3.4, PHP5.6.30
Not working.

shell_exec("in2csv import/21066634-44.7.8.xlsx > /tmp/21066634-44.7.8.xlsx.csv");

It works in the terminal.
in2csv import/21066634-44.7.8.xlsx > /tmp/21066634-44.7.8.xlsx.csv

Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Isagadji, 2017-05-14
@isagadji

The issue was resolved. Found the answer in one of the comments on stackoverflow.com/questions/35437870/selenium-unic...
Before the command, add the locale setting: LANG=en_US.UTF-8 ;

shell_exec("LANG=en_US.UTF-8 ;  in2csv import/21066634-44.7.8.xlsx > /tmp/21066634-44.7.8.xlsx.csv");

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question