如何为pipx安装的codespell添加chardet依赖?
给pipx安装的codespell添加chardet依赖的方法
你之前用pipx install codespell chardet的方式不对——这个命令是把codespell和chardet作为两个独立包分别安装,不会把chardet加到codespell的专属虚拟环境里。正确的操作方式是用pipx的inject命令,步骤如下:
- 执行
pipx inject codespell chardet,该命令会直接将chardet安装到codespell对应的pipx虚拟环境中 - 验证安装结果:运行
pipx runpip codespell list | grep chardet,如果输出chardet的版本信息,说明安装成功 - 之后再运行需要chardet功能的codespell命令,就不会出现依赖缺失的报错了
如果想确认codespell的pipx环境路径,可执行pipx list查看,环境一般位于~/.local/pipx/venvs/codespell目录下,但使用inject命令无需手动操作该路径。
内容的提问来源于stack exchange,提问作者Cornelius Roemer
相关产品推荐
相关产品推荐

