【问题标题】:How to fix UnicodeEncodeError with pyarmor?如何使用 pyarmor 修复 UnicodeEncodeError?
【发布时间】:2021-01-15 00:13:24
【问题描述】:

操作系统:Windows 10 蟒蛇版本:3.8.5 pyarmor 版本:6.4.2

树:

│   .gitignore
│   main.py
│   README.md
│   requirements.txt
│
├───cogs
│   │   somefile.py
│   │   somefile.py
│   │   somefile.py
│   │   somefile.py
│   │   somefile.py
│   │   somefile.py
│   │   somefile.py
│   │   somefile.py
│   │   somefile.py
│   │   somefile.py
│   │
│   └───__pycache__
│           pyc files
│
└───__pycache__
        main.cpython-38.pyc

我想混淆我文件夹中的每个 python 文件。我在 VS 代码中将编码设置为 utf-8,并在每个 python 文件的开头添加了# -*- coding: utf-8 -*-。我正在从 main.py 运行 pyarmor -d obfuscate --recursive main.py,它给了我这个回溯:

Traceback (most recent call last):
  File "c:\users\User\appdata\local\programs\python\python38-32\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\users\User\appdata\local\programs\python\python38-32\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\User\AppData\Local\Programs\Python\Python38-32\Scripts\pyarmor.exe\__main__.py", line 7, in <module>
  File "c:\users\User\appdata\local\programs\python\python38-32\lib\site-packages\pyarmor\pyarmor.py", line 1447, in main_entry
    main(sys.argv[1:])
  File "c:\users\User\appdata\local\programs\python\python38-32\lib\site-packages\pyarmor\pyarmor.py", line 1439, in main
    args.func(args)
  File "c:\users\User\appdata\local\programs\python\python38-32\lib\site-packages\pyarmor\pyarmor.py", line 694, in _obfuscate
    encrypt_script(prokey, a, b, wrap_mode=args.wrap_mode,
  File "c:\users\User\appdata\local\programs\python\python38-32\lib\site-packages\pyarmor\utils.py", line 933, in encrypt_script
    f.write(''.join(lines))
  File "c:\users\User\appdata\local\programs\python\python38-32\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>

在 pyarmor 文档中,他们给出了this 可能的修复方法。我已经这样做了,错误仍然存​​在。

【问题讨论】:

  • 请不要把你的答案放在你的问题上,添加你的答案。然后你就可以接受你的答案了。

标签: python python-3.x pyarmor


【解决方案1】:

编辑: 我已经通过使用pyarmor webui

解决了这个问题

【讨论】:

    猜你喜欢
    • 2017-11-20
    • 2020-09-26
    • 2019-12-24
    • 1970-01-01
    • 2016-08-03
    • 1970-01-01
    • 2022-08-02
    • 1970-01-01
    • 2016-06-16
    相关资源
    最近更新 更多