alingse / emoji-chengyu

把成语转成 emoji 来猜谜的小玩具
MIT License
18 stars 7 forks source link

执行emoji-chengyu-cli 失败 #1

Closed gocpplua closed 1 year ago

gocpplua commented 1 year ago

Traceback (most recent call last): File "/home/chenqi1/.local/bin/emoji-chengyu-cli", line 7, in from emoji_chengyu.main import emoji_chengyu File "/home/chenqi1/.local/lib/python2.7/site-packages/emoji_chengyu/init.py", line 1, in from .data import DefaultChengyuManager, CommonChengyuManager, DefaultEmojiManager # noqa File "/home/chenqi1/.local/lib/python2.7/site-packages/emoji_chengyu/data.py", line 11 SyntaxError: Non-ASCII character '\xc4' in file /home/chenqi1/.local/lib/python2.7/site-packages/emoji_chengyu/data.py on line 11, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

我本地存在下面两个python版本: $ python --version Python 2.7.17

$ python3 --version Python 3.6.9

alingse commented 1 year ago

好的,我看看,系统是啥

alingse commented 1 year ago

应该是需要 python3 运行吧。你最好 pip3 install emoji-chengyu 里面还有一些类型标准的, python2.7 肯定是没法用户了 @gocpplua

gocpplua commented 1 year ago

应该是需要 python3 运行吧。你最好 pip3 install emoji-chengyu 里面还有一些类型标准的, python2.7 肯定是没法用户了 @gocpplua

作者你好,我修改了默认python版本为 python3.6.9: $ python --version Python 3.6.9

执行 pip3正常: $ pip3 install emoji-chengyu Collecting emoji-chengyu Using cached https://files.pythonhosted.org/packages/68/1e/6f7df5a13fbb615b9d9762686a23288bd3ed901eb1e2cd3804936eee0225/emoji-chengyu-0.0.5.tar.gz Collecting click (from emoji-chengyu) Downloading https://files.pythonhosted.org/packages/4a/a8/0b2ced25639fb20cc1c9784de90a8c25f9504a7f18cd8b5397bd61696d7d/click-8.0.4-py3-none-any.whl (97kB) 100% |████████████████████████████████| 102kB 410kB/s Collecting importlib-metadata; python_version < "3.8" (from click->emoji-chengyu) Downloading https://files.pythonhosted.org/packages/a0/a1/b153a0a4caf7a7e3f15c2cd56c7702e2cf3d89b1b359d1f1c5e59d68f4ce/importlib_metadata-4.8.3-py3-none-any.whl Collecting zipp>=0.5 (from importlib-metadata; python_version < "3.8"->click->emoji-chengyu) Downloading https://files.pythonhosted.org/packages/bd/df/d4a4974a3e3957fd1c1fa3082366d7fff6e428ddb55f074bf64876f8e8ad/zipp-3.6.0-py3-none-any.whl Collecting typing-extensions>=3.6.4; python_version < "3.8" (from importlib-metadata; python_version < "3.8"->click->emoji-chengyu) Downloading https://files.pythonhosted.org/packages/45/6b/44f7f8f1e110027cf88956b59f2fad776cca7e1704396d043f89effd3a0e/typing_extensions-4.1.1-py3-none-any.whl Building wheels for collected packages: emoji-chengyu Running setup.py bdist_wheel for emoji-chengyu ... done Stored in directory: /home/chenqi1/.cache/pip/wheels/95/03/f9/e651c6ef5777de0f0e82cfe0f5e2a27412f8099c9384d80d29 Successfully built emoji-chengyu Installing collected packages: zipp, typing-extensions, importlib-metadata, click, emoji-chengyu Successfully installed click-8.0.4 emoji-chengyu-0.0.5 importlib-metadata-4.8.3 typing-extensions-4.1.1 zipp-3.6.0

但是执行emoji-chengyu-cli还是失败,如下: $ emoji-chengyu-cli Traceback (most recent call last): File "/home/chenqi1/.local/bin/emoji-chengyu-cli", line 7, in from emoji_chengyu.main import emoji_chengyu File "/home/chenqi1/.local/lib/python3.6/site-packages/emoji_chengyu/init.py", line 1, in from .data import DefaultChengyuManager, CommonChengyuManager, DefaultEmojiManager # noqa File "/home/chenqi1/.local/lib/python3.6/site-packages/emoji_chengyu/data.py", line 5, in from dataclasses import dataclass ModuleNotFoundError: No module named 'dataclasses'

请问是因为 python3 版本不一样导致的吗?

gocpplua commented 1 year ago

应该是需要 python3 运行吧。你最好 pip3 install emoji-chengyu 里面还有一些类型标准的, python2.7 肯定是没法用户了 @gocpplua

作者你好,我修改了默认python版本为 python3.6.9: $ python --version Python 3.6.9

执行 pip3正常: $ pip3 install emoji-chengyu Collecting emoji-chengyu Using cached https://files.pythonhosted.org/packages/68/1e/6f7df5a13fbb615b9d9762686a23288bd3ed901eb1e2cd3804936eee0225/emoji-chengyu-0.0.5.tar.gz Collecting click (from emoji-chengyu) Downloading https://files.pythonhosted.org/packages/4a/a8/0b2ced25639fb20cc1c9784de90a8c25f9504a7f18cd8b5397bd61696d7d/click-8.0.4-py3-none-any.whl (97kB) 100% |████████████████████████████████| 102kB 410kB/s Collecting importlib-metadata; python_version < "3.8" (from click->emoji-chengyu) Downloading https://files.pythonhosted.org/packages/a0/a1/b153a0a4caf7a7e3f15c2cd56c7702e2cf3d89b1b359d1f1c5e59d68f4ce/importlib_metadata-4.8.3-py3-none-any.whl Collecting zipp>=0.5 (from importlib-metadata; python_version < "3.8"->click->emoji-chengyu) Downloading https://files.pythonhosted.org/packages/bd/df/d4a4974a3e3957fd1c1fa3082366d7fff6e428ddb55f074bf64876f8e8ad/zipp-3.6.0-py3-none-any.whl Collecting typing-extensions>=3.6.4; python_version < "3.8" (from importlib-metadata; python_version < "3.8"->click->emoji-chengyu) Downloading https://files.pythonhosted.org/packages/45/6b/44f7f8f1e110027cf88956b59f2fad776cca7e1704396d043f89effd3a0e/typing_extensions-4.1.1-py3-none-any.whl Building wheels for collected packages: emoji-chengyu Running setup.py bdist_wheel for emoji-chengyu ... done Stored in directory: /home/chenqi1/.cache/pip/wheels/95/03/f9/e651c6ef5777de0f0e82cfe0f5e2a27412f8099c9384d80d29 Successfully built emoji-chengyu Installing collected packages: zipp, typing-extensions, importlib-metadata, click, emoji-chengyu Successfully installed click-8.0.4 emoji-chengyu-0.0.5 importlib-metadata-4.8.3 typing-extensions-4.1.1 zipp-3.6.0

但是执行emoji-chengyu-cli还是失败,如下: $ emoji-chengyu-cli Traceback (most recent call last): File "/home/chenqi1/.local/bin/emoji-chengyu-cli", line 7, in from emoji_chengyu.main import emoji_chengyu File "/home/chenqi1/.local/lib/python3.6/site-packages/emoji_chengyu/init.py", line 1, in from .data import DefaultChengyuManager, CommonChengyuManager, DefaultEmojiManager # noqa File "/home/chenqi1/.local/lib/python3.6/site-packages/emoji_chengyu/data.py", line 5, in from dataclasses import dataclass ModuleNotFoundError: No module named 'dataclasses'

请问是因为 python3 版本不一样导致的吗?

【原因】缺少相关库 【解决】

  1. pip3 install dataclasses
  2. 安装tkinter sudo apt install python3-tk (Ubuntu) yum install python3-tk (Centos)

接下来执行:$ emoji-chengyu-cli 💇‍♂️🙋‍♂️👽🐡 里应外合 🐽👇👩‍🔬🥀 笔下生花 🦢🕸👨‍🎨👨‍🎨 天网恢恢 🌬🌪残☁️ 风卷残云 😃🐜忘👉 乐以忘忧

alingse commented 1 year ago

对,应该是 3.6 之上的版本吧,dataclasses 在 3.6 还不是内置的,后面变成 python3 内置的 我后面在 README.md 里面标一下吧。

alingse commented 1 year ago

对,3.6 不行 https://github.com/alingse/emoji-chengyu/blob/master/.github/workflows/python-package.yml#L16

https://github.com/alingse/emoji-chengyu/commit/be9fd3059f9661effb9a7480686d8d223357bfbf

可以升级下 python3 或者就像你做的 安装一个 dataclasses 就行 @gocpplua

gocpplua commented 1 year ago

对,3.6 不行 https://github.com/alingse/emoji-chengyu/blob/master/.github/workflows/python-package.yml#L16

be9fd30

可以升级下 python3 或者就像你做的 安装一个 dataclasses 就行 @gocpplua

谢谢啊