Coder Social home page Coder Social logo

UnicodeEncodeError about export-saved-reddit HOT 23 OPEN

csu avatar csu commented on May 19, 2024 1
UnicodeEncodeError

from export-saved-reddit.

Comments (23)

netfortius avatar netfortius commented on May 19, 2024 1

Similar issue - but with the " character (u201c) found somewhere:

UnicodeEncodeError: 'ascii' codec can't encode character u'\u201c' in position 17: ordinal not in range(128)

Edit 5/2/2017: pulled and tested the latest version - same issue, apparently somewhere else:

UnicodeEncodeError: 'ascii' codec can't encode character u'\u2019' in position 83: ordinal not in range(128)

from export-saved-reddit.

admish avatar admish commented on May 19, 2024 1

Use Python 3 and this error will clear up.

If you have multiple versions of python installed use python3 export_saved.py to run. You might also need to install praw as well with pip3 install praw.

from export-saved-reddit.

admish avatar admish commented on May 19, 2024 1

@rachmadaniHaryono I just installed this today so have only ever used the latest commit. Running Python 2.7.12 and Python 3.4.2 on macOS 10.12.4. Python3 with praw 4.5 ran flawlessly while Python 2.7 gave the following error:

Version 4.4.0 of praw is outdated. Version 4.5.0 was released 7 days ago.
Traceback (most recent call last):
  File "export_saved.py", line 321, in <module>
    main()
  File "export_saved.py", line 315, in main
    save_saved(reddit)
  File "export_saved.py", line 283, in save_saved
    process(reddit, seq, "export-saved", "Reddit - Saved")
  File "export_saved.py", line 265, in process
    write_csv(csv_rows, file_name + ".csv")
  File "export_saved.py", line 242, in write_csv
    csvwriter.writerow(row)
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2018' in position 10: ordinal not in range(128)

from export-saved-reddit.

admish avatar admish commented on May 19, 2024 1

Yes, I cloned the repo.

By default, OS X comes with Python 2.7. Following the instructions in the README on Macs without knowing this, the script won't work. To anyone else reading this you can change the default version by editing your ~/.bash_profile to include the line alias python='python3' then relaunch your terminal.

If this would help, here is the latest entry in the log.

:~/Workspace/export-saved-reddit$ git log
commit 9841839e273bc8675bc7bb96112650957131fb6c
Merge: 8277d77 5d2ca4b
Author: Christopher Su <[email protected]>
Date:   Wed Apr 26 19:51:43 2017 -0700

    Merge pull request #38 from rachmadaniHaryono/feature/fix-csv-type-error

    fix: usr: TypeError when writing csv field

from export-saved-reddit.

admish avatar admish commented on May 19, 2024 1
Version 4.4.0 of praw is outdated. Version 4.5.0 was released 7 days ago.
Traceback (most recent call last):
  File "export_saved.py", line 329, in <module>
    main()
  File "export_saved.py", line 323, in main
    save_saved(reddit)
  File "export_saved.py", line 287, in save_saved
    process(reddit, seq, "export-saved", "Reddit - Saved")
  File "export_saved.py", line 269, in process
    write_csv(csv_rows, file_name + ".csv")
  File "export_saved.py", line 246, in write_csv
    csvwriter.writerow(row)
UnicodeEncodeError: 'ascii' codec can't encode character u'\u201d' in position 68: ordinal not in range(128)

from export-saved-reddit.

admish avatar admish commented on May 19, 2024 1
Traceback (most recent call last):
  File "export_saved.py", line 339, in <module>
    main()
  File "export_saved.py", line 333, in main
    save_saved(reddit)
  File "export_saved.py", line 297, in save_saved
    process(reddit, seq, "export-saved", "Reddit - Saved")
  File "export_saved.py", line 279, in process
    write_csv(csv_rows, file_name + ".csv")
  File "export_saved.py", line 256, in write_csv
    csvwriter.writerow(row.encode('utf8', 'ignore'))
AttributeError: 'list' object has no attribute 'encode'
 $ git log
commit c8cca7e5f2734d9afd41a05b75f470aafee0f1ce
Author: rachmadaniHaryono <[email protected]>
Date:   Thu May 11 03:32:14 2017 +0800

    chg: dev: fix variable typo

from export-saved-reddit.

admish avatar admish commented on May 19, 2024 1

Setting up a new one now, but also about to leave work so give me a couple hours. In the meantime email me a public key that I can add into the authorized_keys file, and when I have the login info setup I'll share it so you can login.

from export-saved-reddit.

rachmadaniHaryono avatar rachmadaniHaryono commented on May 19, 2024

Thank you @admish for commenting here. Did you use the recent commit with #38?

This could mean this issue can be closed alongside with already closed issue #37 without waiting response @netfortius and @nmandal.

from export-saved-reddit.

rachmadaniHaryono avatar rachmadaniHaryono commented on May 19, 2024

Did you come the repo or just download the export_saved file? If you clone the repo can you check which commit you are now?

I will add program version flag so people can easily recognize the version later.

Also python2.7 is actually not officially supported (and we haven't wrote any python requirement in readme, sorry for that).

But I will patch this python2.7 if the latest pr can't fix it.

  • add program version
  • add python requirement on Readme

from export-saved-reddit.

rachmadaniHaryono avatar rachmadaniHaryono commented on May 19, 2024

@admish can you check once again on python2.7 version?

e: checkout the branch on the pr and run it once again.

e2: actually on requirement it is already recommended to use python3

Requirements

  • Python 3.x

i recommend @netfortius and @nmandal can use python3

the next version i may add an error if python2 is used.

from export-saved-reddit.

admish avatar admish commented on May 19, 2024

Same error.

from export-saved-reddit.

rachmadaniHaryono avatar rachmadaniHaryono commented on May 19, 2024

on the same line? 254 or 256?

from export-saved-reddit.

rachmadaniHaryono avatar rachmadaniHaryono commented on May 19, 2024

@admish can you try it once again?

the recent code c8cca7e

if there is any error there should be only on line number 254, 256, 263, or 265

from export-saved-reddit.

admish avatar admish commented on May 19, 2024

Still the same error.

Version 4.4.0 of praw is outdated. Version 4.5.1 was released 2 days ago.
Traceback (most recent call last):
  File "export_saved.py", line 329, in <module>
    main()
  File "export_saved.py", line 323, in main
    save_saved(reddit)
  File "export_saved.py", line 287, in save_saved
    process(reddit, seq, "export-saved", "Reddit - Saved")
  File "export_saved.py", line 269, in process
    write_csv(csv_rows, file_name + ".csv")
  File "export_saved.py", line 246, in write_csv
    csvwriter.writerow(row)
UnicodeEncodeError: 'ascii' codec can't encode character u'\u201d' in position 68: ordinal not in range(128)

The git pull was successful and this was on the latest merge.

## $ git log
commit 64a37f64037c3eec623ba16de962c7a5da35f1d5
Merge: 9841839 9d4d027
Author: rachmadani haryono <[email protected]>
Date:   Mon May 8 06:51:03 2017 +0800

    Merge pull request #42 from rachmadaniHaryono/feature/add-program-version

    chg: dev: add program version.

from export-saved-reddit.

rachmadaniHaryono avatar rachmadaniHaryono commented on May 19, 2024

yeah, but that isn't the pull request branch.

add my fork and checkout the branch.

git remote add rachmadaniHaryono https://github.com/rachmadaniHaryono/export-saved-reddit
git checkout rachmadaniHaryono/feature/fix-py27-writerow

this should be the result from git show

commit c8cca7e5f2734d9afd41a05b75f470aafee0f1ce
Author: rachmadaniHaryono <[email protected]>
Date:   Thu May 11 03:32:14 2017 +0800

from export-saved-reddit.

rachmadaniHaryono avatar rachmadaniHaryono commented on May 19, 2024

@admish dbe00b0

from export-saved-reddit.

admish avatar admish commented on May 19, 2024
Traceback (most recent call last):
  File "export_saved.py", line 339, in <module>
    main()
  File "export_saved.py", line 333, in main
    save_saved(reddit)
  File "export_saved.py", line 297, in save_saved
    process(reddit, seq, "export-saved", "Reddit - Saved")
  File "export_saved.py", line 279, in process
    write_csv(csv_rows, file_name + ".csv")
  File "export_saved.py", line 256, in write_csv
    csvwriter.writerow([x.encode('utf8', 'ignore') for x in row])
AttributeError: 'int' object has no attribute 'encode'

from export-saved-reddit.

admish avatar admish commented on May 19, 2024

Would you like me to setup an OS X VM for you?

from export-saved-reddit.

rachmadaniHaryono avatar rachmadaniHaryono commented on May 19, 2024

yes, if possible

e:@admish fb3a4b5

from export-saved-reddit.

netfortius avatar netfortius commented on May 19, 2024

Issue is back, at least on OSX. Unicode error, regardless of version of python or praw used. Tried two different machines, one with python2 & praw 4.5.1, and one with python3 and praw 5.0.1. Then upgraded praw on the python2 machine, to cover that combo - consistent error across all: "can't encode character '\xe0' in position 66: ordinal not in range (128)"

from export-saved-reddit.

lukepayne avatar lukepayne commented on May 19, 2024

It looks like this issue wasn't resolved, so I have opened a PR.
@csu could you please take a look / merge if appropriate? Thanks!

from export-saved-reddit.

rachmadaniHaryono avatar rachmadaniHaryono commented on May 19, 2024

Iirc the 3 PRs are actually for this issue, yet nobody mention if the issue is already fixed by one of these

from export-saved-reddit.

lukepayne avatar lukepayne commented on May 19, 2024

You're right, it looks like there are 2 other PR requests that are in various states of completeness. It would be good to have a fix merged in for this issue so that others don't have to run into it.

from export-saved-reddit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.