Twint: [Windows] Python (Anaconda) UnicodeEncodeError

Created on 15 Mar 2018  路  9Comments  路  Source: twintproject/twint

Hello,
When i run it I get this error.How should i fix it?
Traceback (most recent call last):
File "tweep.py", line 289, in
loop.run_until_complete(main())
File "C:\Users\ION\Anaconda3\lib\asyncio\base_events.py", line 467, in run_until_complete
return future.result()
File "tweep.py", line 237, in main
feed, init, count = await getTweets(init)
File "tweep.py", line 206, in getTweets
print(await outTweet(tweet))
File "tweep.py", line 182, in outTweet
writer.writerow(dat)
File "C:\Users\ION\Anaconda3\lib\encodings\cp1253.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode characters in position 92-93: character maps to

question

Most helpful comment

To fix the encoding error,
you can modify line 206 in tweep.py as:
print(output, file=open(arg.o, "a", encoding="utf-8"))

All 9 comments

Could you walk me through the steps you took to get that error?

I tried: python tweep.py --userid 415859364 --year 2014 -o file1.csv --csv

Which version of Python3 are you using?

This seems similar to https://github.com/dbcli/pgcli/issues/628.

One of the solutions described was upgrading to Python 3.6

I use Python 3.6.4

Okay, I think this may be fixed in the latest commit. Can you try it again?

After trying the latest commit I get the error below:
Traceback (most recent call last):
File "tweep.py", line 289, in
loop.run_until_complete(main())
File "C:\Users\ION\Anaconda3\lib\asyncio\base_events.py", line 467, in run_until_complete
return future.result()
File "tweep.py", line 237, in main
feed, init, count = await getTweets(init)
File "tweep.py", line 196, in getTweets
tweets, init = await getFeed(init)
File "tweep.py", line 94, in getFeed
response = await fetch(session, await getUrl(init))
File "tweep.py", line 57, in fetch
async with session.get(url) as response:
File "C:\Users\ION\Anaconda3\lib\site-packages\aiohttp\client.py", line 779, in __aenter__
self._resp = await self._coro
File "C:\Users\ION\Anaconda3\lib\site-packages\aiohttp\client.py", line 331, in _request
await resp.start(conn, read_until_eof)
File "C:\Users\ION\Anaconda3\lib\site-packages\aiohttp\client_reqrep.py", line 678, in start
(message, payload) = await self._protocol.read()
File "C:\Users\ION\Anaconda3\lib\site-packages\aiohttp\streams.py", line 533, in read
await self._waiter
aiohttp.client_exceptions.ClientOSError: [WinError 10054]

That's it? hmm strange

To fix the encoding error,
you can modify line 206 in tweep.py as:
print(output, file=open(arg.o, "a", encoding="utf-8"))

Was this page helpful?
0 / 5 - 0 ratings