Closed MichaelC001 closed 1 year ago
确实不应该直接到site-packages文件夹直接运行脚本的,那样会导致相对目录导入包错误。 你可以通过pip包运行gpt-term:
pip -m gpt_term
或者直接运行gpt-term
gpt-term
如果想要直接运行chat.py文件,可以先把这个 repo 克隆到本地后运行此目录下的chat.py
git clone https://github.com/xiaoxx970/chatgpt-in-terminal
cd chatgpt-in-terminal
python3 chat.py
pip show gpt-term 显示gpt-term 文件夹如下 /opt/homebrew/Caskroom/miniconda/base/lib/python3.10/site-packages/gpt_term 这个文件夹下面没有chat.py这个文件 我进入这个文件夹 运行python main.py 报错
Traceback (most recent call last): File "/opt/homebrew/Caskroom/miniconda/base/lib/python3.10/site-packages/gpt_term/main.py", line 23, in
import tiktoken
File "/opt/homebrew/Caskroom/miniconda/base/lib/python3.10/site-packages/tiktoken/init.py", line 1, in
from .core import Encoding as Encoding
File "/opt/homebrew/Caskroom/miniconda/base/lib/python3.10/site-packages/tiktoken/core.py", line 7, in
import regex
File "/opt/homebrew/Caskroom/miniconda/base/lib/python3.10/site-packages/regex/init.py", line 1, in
from .regex import *
File "/opt/homebrew/Caskroom/miniconda/base/lib/python3.10/site-packages/regex/regex.py", line 424, in
from locale import getpreferredencoding as _getpreferredencoding
ImportError: cannot import name 'getpreferredencoding' from 'locale' (/opt/homebrew/Caskroom/miniconda/base/lib/python3.10/site-packages/gpt_term/locale.py)
======================= 但是直接用pip安装后,运行gpt-term 没问题