Trying to invoke the aws cli from php, but a simple test shell_exec('aws help');
will result in the following error:
Traceback (most recent call last):
File "aws", line 27, in <module>
File "aws", line 23, in main
File "awscli\clidriver.pyc", line 59, in main
File "awscli\clidriver.pyc", line 197, in main
File "awscli\argparser.pyc", line 100, in parse_known_args
LookupError: unknown encoding: cp65001
It works perfectly fine when running directly in command-window (cmd.exe).
Python version:
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:06:47) [MSC v.1914 32 bit (Intel)] on win32
For some reason shell_exec is defaulting to use utf8 / cp65001...
Finally found a solution after trying to set different locale config and php settings.
A call to chcp
before any shell_exec
solved it!
exec("chcp 850");