Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnicodeEncodeError: 'charmap' codec can't encode character '\u202f' in position 54: character maps to <undefined> encoding with 'cp437' codec failed #184

Open
codejoey opened this issue Mar 1, 2024 · 11 comments

Comments

@codejoey
Copy link

codejoey commented Mar 1, 2024

Tried to view an export zip via Mac terminal.

Ran into this error which halts it. Any ideas?

Traceback (most recent call last):
File "/Users/Joey/.local/bin/slack-export-viewer", line 10, in
sys.exit(main())
^^^^^^
File "/Users/Joey/Library/Application Support/pipx/venvs/slack-export-viewer/lib/python3.12/site-packages/click/core.py", line 1157, in call
return self.main(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/Joey/Library/Application Support/pipx/venvs/slack-export-viewer/lib/python3.12/site-packages/click/core.py", line 1078, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "/Users/Joey/Library/Application Support/pipx/venvs/slack-export-viewer/lib/python3.12/site-packages/click/core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/Joey/Library/Application Support/pipx/venvs/slack-export-viewer/lib/python3.12/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/Joey/Library/Application Support/pipx/venvs/slack-export-viewer/lib/python3.12/site-packages/slackviewer/main.py", line 79, in main
configure_app(app, archive, channels, no_sidebar, no_external_references, debug)
File "/Users/Joey/Library/Application Support/pipx/venvs/slack-export-viewer/lib/python3.12/site-packages/slackviewer/main.py", line 21, in configure_app
path = extract_archive(archive)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/Joey/Library/Application Support/pipx/venvs/slack-export-viewer/lib/python3.12/site-packages/slackviewer/archive.py", line 74, in extract_archive
info.filename = info.filename.encode("cp437").decode("utf-8")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/python@3.12/3.12.2_1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/encodings/cp437.py", line 12, in encode
return codecs.charmap_encode(input,errors,encoding_map)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeEncodeError: 'charmap' codec can't encode character '\u202f' in position 54: character maps to
encoding with 'cp437' codec failed

@gunchev
Copy link
Contributor

gunchev commented Apr 10, 2024

I managed to get something working by first extracting the archive in a new directory and then point the viewer to that. I know, workaround, but haven't debugged it. It was trying to decore an utf-8 string using cp437.

@BLiu1
Copy link

BLiu1 commented Jul 13, 2024

I ran into the same error. Did you happen to export from slackdump? It might be that slackdump is using UTF-8 instead of cp437 for the zip file.

@aalkz
Copy link
Contributor

aalkz commented Aug 9, 2024

I had this problem too, it was complaining about files with áéíóú characters in them. My temporay solution was to comment this line and suddenly it worked fine:

# info.filename = info.filename.encode("cp437").decode("utf-8")

info.filename = info.filename.encode("cp437").decode("utf-8")

I don't know why that encoding conversion is there in the first place though, I feel that it shouldn't be necessary and it creates problems for people that don't have English as their default language. 🤔

@jiangyi1985
Copy link

same problem

@conjon42
Copy link

conjon42 commented Oct 5, 2024

Same problem, using an archive from slackdump on MacOS.

@laviddichterman
Copy link

+1. From slackdump on MacOS installed with homebrew.

@hfaran
Copy link
Owner

hfaran commented Jan 21, 2025

I had this problem too, it was complaining about files with áéíóú characters in them. My temporay solution was to comment this line and suddenly it worked fine:

# info.filename = info.filename.encode("cp437").decode("utf-8")

slack-export-viewer/slackviewer/archive.py

Line 74 in 0e82996
info.filename = info.filename.encode("cp437").decode("utf-8")

I don't know why that encoding conversion is there in the first place though, I feel that it shouldn't be necessary and it creates problems for people that don't have English as their default language. 🤔

@aalkz that change was added in this PR: #166 - if other people can confirm that reverting this change unblocks them then this change can be reverted (or perhaps added as an option in the program to enable or not).

@Souukou
Copy link

Souukou commented Jan 25, 2025

I had this problem too, it was complaining about files with áéíóú characters in them. My temporay solution was to comment this line and suddenly it worked fine:
# info.filename = info.filename.encode("cp437").decode("utf-8")
slack-export-viewer/slackviewer/archive.py
Line 74 in 0e82996
info.filename = info.filename.encode("cp437").decode("utf-8")
I don't know why that encoding conversion is there in the first place though, I feel that it shouldn't be necessary and it creates problems for people that don't have English as their default language. 🤔

@aalkz that change was added in this PR: #166 - if other people can confirm that reverting this change unblocks them then this change can be reverted (or perhaps added as an option in the program to enable or not).

I had the same problem, comment out the line unblocked me. However, it won't be able to show the direct messages. and I don't know if this is related to this line of code or a unrelated known problem.

@volker-fr
Copy link
Contributor

it won't be able to show the direct messages

There is a PR to revert the old default: #218

In the mean time, with the latest version you can use the command line flag --show-dms

@WarrenFaith
Copy link

in my case this was due to user names with accented characters like é etc.
I unzipped the file, opened the users.json and replaced all accented characters there. Zipped it again and generating with --html-only worked again.

@luckyvickyricky
Copy link

I encountered the same issue with Korean as well. Commenting out the line at this location resolved the problem for me.

info.filename = info.filename.encode("cp437").decode("utf-8")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests