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 #57

Closed
NadieFiind opened this issue Oct 15, 2022 · 4 comments
Closed

UnicodeEncodeError #57

NadieFiind opened this issue Oct 15, 2022 · 4 comments

Comments

@NadieFiind
Copy link

An issue related to this is already closed. But it seems that it is not yet completely fixed.

The error occurs on emojis.

This is the exact command I used:

pyminify folder --in-place --remove-literal-statements

Versions:

  • python 3.10.7
  • python-minifier 2.6.0
@dflook
Copy link
Owner

dflook commented Oct 15, 2022

Hello @NadieFiind, can you share the source you are trying to minify and the output from pyminify?

@NadieFiind
Copy link
Author

NadieFiind commented Oct 15, 2022

Also, I have only encountered this error on Windows. But it works fine on Linux.

Source:
https://github.com/pyfyre/pyfyre/blob/rewrite/pyfyre_cli/user/src/index.py
Specifically on line 8 at the emojis. If I remove the emojis, pyminify works fine.

Output:

__temp__\index.py
Traceback (most recent call last):
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2032.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2032.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\infan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\Scripts\pyminify.exe\__main__.py", line 7, in <module>
  File "C:\Users\infan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\python_minifier\__main__.py", line 64, in main
    f.write(minified)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2032.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 177-178: character maps to <undefined>

@dflook
Copy link
Owner

dflook commented Oct 15, 2022

Thanks. I'm not familiar with windows but it looks like python is using a different encoding instead of utf-8.
Could you set the environment variable PYTHONUTF8=1 and see if it works?

@NadieFiind
Copy link
Author

@dflook Oh yes, it works now. Thanks!

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

No branches or pull requests

2 participants