question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Instant error when running script

See original GitHub issue

When I run the script I get this error instantly: Traceback (most recent call last): File "twitterbot1.py", line 67, in <module> run() File "twitterbot1.py", line 62, in run search(api.search(q=key)) File "twitterbot1.py", line 37, in search if is_user_bot_hunter(str(i.author.name), str(i.author.screen_name)) == False: UnicodeEncodeError: 'ascii' codec can't encode character u'\U0001f384' in position 0: ordinal not in range(128)

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Alkesstcommented, Jan 14, 2018

This error usually appears when using python 2.x due to the string encoding. Python 2.x uses ascii strings by default. It is required to use .encode(‘utf8’)/.decode(‘utf8’) in the right strings to avoid getting the error. Other way to avoid the error is by adding u"just a string" to all the strings. (I regret for my bad english, I hope it helps)

P.S. Tweepy uses by default the unicode strings.

0reactions
PascalvanDongencommented, Jan 8, 2018

Now i am getting this error: Traceback (most recent call last): File "twitterbot.py", line 67, in <module> run() File "twitterbot.py", line 62, in run search(api.search(q=key)) File "/usr/local/lib/python2.7/dist-packages/tweepy/binder.py", line 245, in _call return method.execute() File "/usr/local/lib/python2.7/dist-packages/tweepy/binder.py", line 229, in execute raise TweepError(error_msg, resp, api_code=api_error_code) tweepy.error.TweepError: [{u'message': u'Invalid or expired token.', u'code': 89}]

Read more comments on GitHub >

github_iconTop Results From Across the Web

Script Errors (What They Are and How to Fix Them) - Lifewire
A script error is an error that occurs when the instructions from a script can't be executed correctly for some reason.
Read more >
What Is a Script Error: Causes and How to Fix Them - Sematext
Script Error is a special kind of error that you get when a runtime or syntax error occurs in a script that is...
Read more >
How to fix Script Error in Windows? - ugetfix.com
Solution 5. Turn off Scripting Errors in IE · Press the Windows Key + R key to open the Run box · Type...
Read more >
How to Fix 'An Error Has Occurred in the Script On This Page ...
How to Fix 'An Error Has Occurred in the Script On This Page' [Tutorial" Run " Text:Regsvr32 urlmon.dllYou might have been buffering an...
Read more >
Script errors in Internet Explorer - Browsers - Microsoft Learn
If an antivirus program interprets a script as a virus, and prevents it from running, a script error may occur. To prevent this...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found