Jan-12-2022, 07:46 AM
I am running a python program from another python program using subprocess.Popen, specifically like this
Here's the entire traceback of the error:
subprocess.Popen(['python', self.path], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
. I also tried specifying the encoding and errors parameters like so subprocess.Popen(['python', self.path], stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding='utf-8', errors='utf-8')
, which did not fix the error.Here's the entire traceback of the error:
Error:Traceback (most recent call last):
File "main.py", line 768, in <module>
bot.loop.run_until_complete(bot.start())
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2800.0_x64__qbz5n2kfra8p0\lib\asyncio\base_events.py", line 616, in run_until_complete
return future.result()
File "main.py", line 297, in start
print(future.result())
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2800.0_x64__qbz5n2kfra8p0\lib\concurrent\futures\_base.py", line 437, in result
return self.__get_result()
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2800.0_x64__qbz5n2kfra8p0\lib\concurrent\futures\_base.py", line 389, in __get_result
raise self._exception
File "main.py", line 350, in poll
await self.on_message(user, channel, content, tags)
File "main.py", line 412, in on_message
await self.commands[command](user, channel, args)
File "main.py", line 40, in check
return await func(self, user, channel, args, *eargs, **kwargs)
File "main.py", line 440, in pull
await self.send_message(channel,
File "main.py", line 378, in send_message
print(f"> PRIVMSG #{chnl} :{message}")
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.2800.0_x64__qbz5n2kfra8p0\lib\encodings\cp1252.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode characters in position 60-62: character maps to <undefined>
If I were to run the program from the command line with python, it runs just fine. However, as a subprocess, it seems to have trouble encoding certain characters. I would like some help figuring out the cause of the error and how I can fix it.