alibaba / web-editor

please use https://uiauto.dev instead
https://uiauto.dev
MIT License
1.24k stars 307 forks source link

Python 3.8.6安装报错 #145

Open shaoerkuai opened 11 months ago

shaoerkuai commented 11 months ago

error in setup command: Error parsing C:\Users\XXXXX\AppData\Local\Temp\pip-install-yoos76uw\weditor_4cbafa603c944b2cb8df247601bc893d\setup.cfg: UnicodeDecodeEr ror: 'gbk' codec can't decode byte 0xad in position 645: illegal multibyte sequence

kerneltravel commented 11 months ago

@shaoerkuai 这个问题在python3的各版本都存在。

原因

一个文件(PKG-INFO ) 里包含中文字符 [中文文档]

解决方式1

可以将 0.7.2 版本的we-editor 代码https://files.pythonhosted.org/packages/a1/c6/ec92e8d4a95f4e901e3b6764e1b716ac85dd9892d36d5f40fef6063cdbd6/weditor-0.7.2.tar.gz 压缩包在本地解压后,将(PKG-INFO ) 文件里的中文去掉,然后在目录里执行

python setup.py install

来安装这个模块。

解决方式2

如果不想删掉PKG-INFO 文件内容中文字符,那么可以修改 上述压缩包解压得到的 .eggs\pbr-5.11.1-py3.7.egg\pbr\packaging.py 代码文件的 821行

https://github.com/openstack/pbr/blame/11151154b94f5e116c0ec8cd312df8d341553d50/pbr/packaging.py#L821C20-L821C20 这一行从

with open(filename, 'r') as pkg_metadata_file:

改为

with open(filename, 'r', encoding="utf8") as pkg_metadata_file:

以支持包含中文字符串的文件。

xmhwws commented 11 months ago

@codeskyblue 作者大大,能否根据上面给的方案修复一下编码问题? pip安装最新版失败....

shaoerkuai commented 11 months ago

方式二:启用Windows的Unicode UTF8支持,不需要修改任何内容,但会让某些古老软件乱码,可以启用后,安装成功再关闭。

这个应该要推openstack pbr那边去解决

lihuaming07 commented 6 months ago

方式二:启用Windows的Unicode UTF8支持,不需要修改任何内容,但会让某些古老软件乱码,可以启用后,安装成功再关闭。

设置系统的Python的环境变量也可以,重启CMD后生效

set PYTHONUTF8=1

shaoerkuai commented 6 months ago

最新版本应该已经修复掉了

xmhwws commented 6 months ago

最新版本应该已经修复掉了

@shaoerkuai 最新版0.7.2,pip安装,仍旧失败!这个issue需要reopen!

image

pip3 install -U weditor
WARNING: Ignoring invalid distribution -editor (d:\python\lib\site-packages)
WARNING: Ignoring invalid distribution -illow (d:\python\lib\site-packages)
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Requirement already satisfied: weditor in d:\python\lib\site-packages (0.6.4)
Collecting weditor
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/a1/c6/ec92e8d4a95f4e901e3b6764e1b716ac85dd9892d36d5f40fef6063cdbd6/weditor-0.7.2.tar.gz (2.2 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.2/2.2 MB 4.5 MB/s eta 0:00:00
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Preparing metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [22 lines of output]
      Error parsing
      Traceback (most recent call last):
        File "C:\Users\admin\AppData\Local\Temp\pip-build-env-ioru3wxq\normal\Lib\site-packages\pbr\core.py", line 105, in pbr
          attrs = util.cfg_to_args(path, dist.script_args)
        File "C:\Users\admin\AppData\Local\Temp\pip-build-env-ioru3wxq\normal\Lib\site-packages\pbr\util.py", line 272, in cfg_to_args
          pbr.hooks.setup_hook(config)
        File "C:\Users\admin\AppData\Local\Temp\pip-build-env-ioru3wxq\normal\Lib\site-packages\pbr\hooks\__init__.py", line 25, in setup_hook
          metadata_config.run()
        File "C:\Users\admin\AppData\Local\Temp\pip-build-env-ioru3wxq\normal\Lib\site-packages\pbr\hooks\base.py", line 27, in run
          self.hook()
        File "C:\Users\admin\AppData\Local\Temp\pip-build-env-ioru3wxq\normal\Lib\site-packages\pbr\hooks\metadata.py", line 26, in hook
          self.config['name'], self.config.get('version', None))
        File "C:\Users\admin\AppData\Local\Temp\pip-build-env-ioru3wxq\normal\Lib\site-packages\pbr\packaging.py", line 854, in get_version
          version = _get_version_from_pkg_metadata(package_name)
        File "C:\Users\admin\AppData\Local\Temp\pip-build-env-ioru3wxq\normal\Lib\site-packages\pbr\packaging.py", line 822, in _get_version_from_pkg_metadata
          pkg_metadata = email.message_from_file(pkg_metadata_file)
        File "D:\Python\lib\email\__init__.py", line 54, in message_from_file
          return Parser(*args, **kws).parse(fp)
        File "D:\Python\lib\email\parser.py", line 53, in parse
          data = fp.read(8192)
      UnicodeDecodeError: 'gbk' codec can't decode byte 0xad in position 645: illegal multibyte sequence
      error in setup command: Error parsing C:\Users\admin\AppData\Local\Temp\pip-install-agserho8\weditor_d06c731e4aa34b3dabba6cba42dd029a\setup.cfg: UnicodeDecodeError: 'gbk' codec can't decode byte 0xad in position 645: illegal multibyte sequence
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
shaoerkuai commented 6 months ago

最新版本应该已经修复掉了

@shaoerkuai 最新版0.7.2,pip安装,仍旧失败!这个issue需要reopen!

image

pip3 install -U weditor
WARNING: Ignoring invalid distribution -editor (d:\python\lib\site-packages)
WARNING: Ignoring invalid distribution -illow (d:\python\lib\site-packages)
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Requirement already satisfied: weditor in d:\python\lib\site-packages (0.6.4)
Collecting weditor
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/a1/c6/ec92e8d4a95f4e901e3b6764e1b716ac85dd9892d36d5f40fef6063cdbd6/weditor-0.7.2.tar.gz (2.2 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.2/2.2 MB 4.5 MB/s eta 0:00:00
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Preparing metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [22 lines of output]
      Error parsing
      Traceback (most recent call last):
        File "C:\Users\admin\AppData\Local\Temp\pip-build-env-ioru3wxq\normal\Lib\site-packages\pbr\core.py", line 105, in pbr
          attrs = util.cfg_to_args(path, dist.script_args)
        File "C:\Users\admin\AppData\Local\Temp\pip-build-env-ioru3wxq\normal\Lib\site-packages\pbr\util.py", line 272, in cfg_to_args
          pbr.hooks.setup_hook(config)
        File "C:\Users\admin\AppData\Local\Temp\pip-build-env-ioru3wxq\normal\Lib\site-packages\pbr\hooks\__init__.py", line 25, in setup_hook
          metadata_config.run()
        File "C:\Users\admin\AppData\Local\Temp\pip-build-env-ioru3wxq\normal\Lib\site-packages\pbr\hooks\base.py", line 27, in run
          self.hook()
        File "C:\Users\admin\AppData\Local\Temp\pip-build-env-ioru3wxq\normal\Lib\site-packages\pbr\hooks\metadata.py", line 26, in hook
          self.config['name'], self.config.get('version', None))
        File "C:\Users\admin\AppData\Local\Temp\pip-build-env-ioru3wxq\normal\Lib\site-packages\pbr\packaging.py", line 854, in get_version
          version = _get_version_from_pkg_metadata(package_name)
        File "C:\Users\admin\AppData\Local\Temp\pip-build-env-ioru3wxq\normal\Lib\site-packages\pbr\packaging.py", line 822, in _get_version_from_pkg_metadata
          pkg_metadata = email.message_from_file(pkg_metadata_file)
        File "D:\Python\lib\email\__init__.py", line 54, in message_from_file
          return Parser(*args, **kws).parse(fp)
        File "D:\Python\lib\email\parser.py", line 53, in parse
          data = fp.read(8192)
      UnicodeDecodeError: 'gbk' codec can't decode byte 0xad in position 645: illegal multibyte sequence
      error in setup command: Error parsing C:\Users\admin\AppData\Local\Temp\pip-install-agserho8\weditor_d06c731e4aa34b3dabba6cba42dd029a\setup.cfg: UnicodeDecodeError: 'gbk' codec can't decode byte 0xad in position 645: illegal multibyte sequence
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

set PYTHONUTF8=1 先操作下吧

xmhwws commented 6 months ago

@shaoerkuai 还是不行 依次执行:

set PYTHONUTF8=1
pip3 install -U weditor

image

lihuaming07 commented 6 months ago

是要在系统的环境变量里面设置,你去百度搜搜修改系统环境变量,然后重启一下cmd,再输入命令。

xmhwws commented 5 months ago

是要在系统的环境变量里面设置,你去百度搜搜修改系统环境变量,然后重启一下cmd,再输入命令。

win11,在用户环境变量里面添加,重启电脑,可以正常安装最新版了; 不过,使用后,发现对手机界面元素分析有点问题。

codeskyblue commented 5 months ago

换这个呗,我重新写的 https://uiauto.dev

xmhwws commented 5 months ago

换这个呗,我重新写的 https://uiauto.dev

这个要python3.8+,我电脑是3.7,用不了