记录在树莓派中部署PI-Assistant开源项目(GPT语音对话)的BUG

核心

在部署PI-Assistant(https://github.com/Lucky-183/PI-Assistant)项目中,首先要进行环境安装,官网文档中提供的安装命令如下:

pip install requests arcade RPi.GPIO pydub numpy wave sounddevice pymysql cn2an duckduckgo_search flask SpeechRecognition openai pyaudio websocket-client paho-mqtt

如果按照此命令安装,多半会出现问题。不是安装命令有问题,而是安装环境、设备、网络等等综合原因,导致一次性安装上面那么多的组件是有些困难的。

  • 解决:

1、分开一个个安装。

2、当安装出现超时,采用国内镜像安装,比如:pip install -i https://mirrors.aliyun.com/pypi/simple/ SpeechRecognition

3、安装中出现hash验证出问题,建议手动下载安装包进行安装。在https://pypi.org/网站上搜索并下载最新版本安装包。安装命令在文章下面有提到。

4、在执行python server.py过程中,还有一些需要安装的module,缺什么再单独安装什么。

(进过我的验证,按照上述方法,成功安装所有依赖并启动成功!如有疑问可以留言。)

BUG描述:

我的问题是要在树莓派上执行如下命令:

 pip install requests arcade RPi.GPIO pydub numpy wave sounddevice pymysql cn2an duckduckgo_search flask SpeechRecognition openai pyaudio websocket-client

执行过程中出现如下错误:

ERROR: Exception:
Traceback (most recent call last):
  File "/usr/share/python-wheels/resolvelib-0.5.4-py2.py3-none-any.whl/resolvelib/resolvers.py", line 171, in _merge_into_criterion
    crit = self.state.criteria[name]
KeyError: 'speechrecognition'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/share/python-wheels/urllib3-1.26.5-py2.py3-none-any.whl/urllib3/response.py", line 438, in _error_catcher
    yield
  File "/usr/share/python-wheels/urllib3-1.26.5-py2.py3-none-any.whl/urllib3/response.py", line 519, in read
    data = self._fp.read(amt) if not fp_closed else b""
  File "/usr/share/python-wheels/CacheControl-0.12.6-py2.py3-none-any.whl/cachecontrol/filewrapper.py", line 62, in read
    data = self.__fp.read(amt)
  File "/usr/lib/python3.9/http/client.py", line 458, in read
    n = self.readinto(b)
  File "/usr/lib/python3.9/http/client.py", line 502, in readinto
    n = self.fp.readinto(b)
  File "/usr/lib/python3.9/socket.py", line 704, in readinto
    return self._sock.recv_into(b)
  File "/usr/lib/python3.9/ssl.py", line 1241, in recv_into
    return self.read(nbytes, buffer)
  File "/usr/lib/python3.9/ssl.py", line 1099, in read
    return self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pip/_internal/cli/base_command.py", line 223, in _main
    status = self.run(options, args)
  File "/usr/lib/python3/dist-packages/pip/_internal/cli/req_command.py", line 180, in wrapper
    return func(self, options, args)
  File "/usr/lib/python3/dist-packages/pip/_internal/commands/install.py", line 346, in run
    requirement_set = resolver.resolve(
  File "/usr/lib/python3/dist-packages/pip/_internal/resolution/resolvelib/resolver.py", line 122, in resolve
    self._result = resolver.resolve(
  File "/usr/share/python-wheels/resolvelib-0.5.4-py2.py3-none-any.whl/resolvelib/resolvers.py", line 453, in resolve
    state = resolution.resolve(requirements, max_rounds=max_rounds)
  File "/usr/share/python-wheels/resolvelib-0.5.4-py2.py3-none-any.whl/resolvelib/resolvers.py", line 318, in resolve
    name, crit = self._merge_into_criterion(r, parent=None)
  File "/usr/share/python-wheels/resolvelib-0.5.4-py2.py3-none-any.whl/resolvelib/resolvers.py", line 173, in _merge_into_criterion
    crit = Criterion.from_requirement(self._p, requirement, parent)
  File "/usr/share/python-wheels/resolvelib-0.5.4-py2.py3-none-any.whl/resolvelib/resolvers.py", line 82, in from_requirement
    if not cands:
  File "/usr/share/python-wheels/resolvelib-0.5.4-py2.py3-none-any.whl/resolvelib/structs.py", line 124, in __bool__
    return bool(self._sequence)
  File "/usr/lib/python3/dist-packages/pip/_internal/resolution/resolvelib/found_candidates.py", line 99, in __bool__
    return any(self)
  File "/usr/lib/python3/dist-packages/pip/_internal/resolution/resolvelib/factory.py", line 239, in iter_index_candidates
    candidate = self._make_candidate_from_link(
  File "/usr/lib/python3/dist-packages/pip/_internal/resolution/resolvelib/factory.py", line 167, in _make_candidate_from_link
    self._link_candidate_cache[link] = LinkCandidate(
  File "/usr/lib/python3/dist-packages/pip/_internal/resolution/resolvelib/candidates.py", line 296, in __init__
    super(LinkCandidate, self).__init__(
  File "/usr/lib/python3/dist-packages/pip/_internal/resolution/resolvelib/candidates.py", line 144, in __init__
    self.dist = self._prepare()
  File "/usr/lib/python3/dist-packages/pip/_internal/resolution/resolvelib/candidates.py", line 222, in _prepare
    dist = self._prepare_distribution()
  File "/usr/lib/python3/dist-packages/pip/_internal/resolution/resolvelib/candidates.py", line 307, in _prepare_distribution
    return self._factory.preparer.prepare_linked_requirement(
  File "/usr/lib/python3/dist-packages/pip/_internal/operations/prepare.py", line 480, in prepare_linked_requirement
    return self._prepare_linked_requirement(req, parallel_builds)
  File "/usr/lib/python3/dist-packages/pip/_internal/operations/prepare.py", line 503, in _prepare_linked_requirement
    local_file = unpack_url(
  File "/usr/lib/python3/dist-packages/pip/_internal/operations/prepare.py", line 253, in unpack_url
    file = get_http_url(
  File "/usr/lib/python3/dist-packages/pip/_internal/operations/prepare.py", line 130, in get_http_url
    from_path, content_type = download(link, temp_dir.path)
  File "/usr/lib/python3/dist-packages/pip/_internal/network/download.py", line 163, in __call__
    for chunk in chunks:
  File "/usr/lib/python3/dist-packages/pip/_internal/cli/progress_bars.py", line 168, in iter
    for x in it:
  File "/usr/lib/python3/dist-packages/pip/_internal/network/utils.py", line 64, in response_chunks
    for chunk in response.raw.stream(
  File "/usr/share/python-wheels/urllib3-1.26.5-py2.py3-none-any.whl/urllib3/response.py", line 576, in stream
    data = self.read(amt=amt, decode_content=decode_content)
  File "/usr/share/python-wheels/urllib3-1.26.5-py2.py3-none-any.whl/urllib3/response.py", line 541, in read
    raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
  File "/usr/lib/python3.9/contextlib.py", line 135, in __exit__
    self.gen.throw(type, value, traceback)
  File "/usr/share/python-wheels/urllib3-1.26.5-py2.py3-none-any.whl/urllib3/response.py", line 443, in _error_catcher
    raise ReadTimeoutError(self._pool, None, "Read timed out.")
urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='www.piwheels.org', port=443): Read timed out.

解决

1、升级pip的版本

这个错误是因为pip低版本中存在一点BUG,升级到最新版本就可以。

将上述安装包上传到树莓派中(我是在树莓派中出现的此问题),解压之后进入文件夹执行下面命令:

sudo python setup.py install
  • 安装包升级:官网自行下载。
    官网地址: https://pypi.org/ 在首页搜索框中输入pip即可。如下图所示:

    之后回车进入下面界面:

    如上图,选择最新版本进入即可,就会有下载的按钮,如下图:

新问题1:ERROR: THESE PACKAGES DO NOT MATCH THE HASHES FROM THE REQUIREMENTS FILE

ERROR: THESE PACKAGES DO NOT MATCH THE HASHES FROM THE REQUIREMENTS FILE. If you have updated the package versions, please update the hashes. Otherwise, examine the package contents carefully; someone may have tampered with them.
    SpeechRecognition from https://www.piwheels.org/simple/speechrecognition/SpeechRecognition-3.10.1-py2.py3-none-any.whl#sha256=2e1e47088e06ecf0b45e5ca0f0e21770d2d9bead1a848d93751bc724fc868ce4:
        Expected sha256 2e1e47088e06ecf0b45e5ca0f0e21770d2d9bead1a848d93751bc724fc868ce4
             Got        e2dfc76386f2da3de7537c7cfb9ce635aaf218aad5060a05c66f2351440f6cd8 

上述问题提示,遇到的错误信息表明安装的软件包哈希值与你的要求文件中指定的哈希值不匹配。这种不一致可能是由于在没有更新要求文件中相应哈希值的情况下更新了软件包版本引起的。

解决:

1、执行命令

pip freeze > requirements.txt

2、执行命令

sudo pip uninstall -r requirements.txt -y

3、执行命令

sudo pip install -r requirements.txt

新问题2:ERROR: Could not find a version that satisfies the requirement numpy==1.19.5 (from versions: none)

ERROR: No matching distribution found for numpy==1.19.5

解决:

安装numpy命令如下(使用清华镜像安装):

pip3 install numpy scipy matplotlib -i https://pypi.tuna.tsinghua.edu.cn/simple
相关推荐
sinovoip2 小时前
Banana Pi BPI-CanMV-K230D-Zero 采用嘉楠科技 K230D RISC-V芯片设计
人工智能·科技·物联网·开源·risc-v
OpenAnolis小助手2 小时前
开源生态发展合作倡议
开源·操作系统·龙蜥社区·龙蜥·openanolis
z千鑫3 小时前
【人工智能】深入理解PyTorch:从0开始完整教程!全文注解
人工智能·pytorch·python·gpt·深度学习·ai编程
杭州奥能充电桩3 小时前
移动充储机器人“小奥”的多场景应用(上)
开源·能源
蚂蚁数据AntData4 小时前
DB-GPT V0.6.2 版本更新:牵手libro社区、GraphRAG图谱构建能力增强等
gpt
机智的小神仙儿7 小时前
GPT-1.0、GPT-2.0、GPT-3.0参数对比
gpt·语言模型·gpt-3
Landy_Jay8 小时前
深度学习:GPT-1的MindSpore实践
人工智能·gpt·深度学习
skywalk81638 小时前
树莓派2 安装raspberry os 并修改成固定ip
linux·服务器·网络·debian·树莓派·raspberry
hunteritself1 天前
ChatGPT高级语音模式正在向Web网页端推出!
人工智能·gpt·chatgpt·openai·语音识别
lsjweiyi1 天前
极简AI工具箱网站开源啦!
opencv·开源·微信支付·支付宝支付·百度ai·极简ai工具箱·ai图像处理