'SyntaxError: (unicode error) 'utf-8' codec can't decode byte 0xe1 in position 9: invalid continuation byte

I have the following sh file:

#!/bin/bash

python <py_filename>.py

The file filename.py begins with

#!/usr/bin/env python
# coding: utf-8

and contains a list of strings with special characters like ã and ç.

When I do

sh <sh_filename>.sh

The following error is returned:

SyntaxError: (unicode error) 'utf-8' codec can't decode byte 0xe1 in position 9: invalid continuation byte

and I can see that, for instance, the word 'Ações' is represented as 'A��es'.

I understand that is something related to file encoding but I don't know how to solve it.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source