pipx安装black后缺失aiohttp依赖及Python版本不符问题求助
问题详情
通过brew安装pipx后,使用pipx安装black:
$ brew install pipx ... $ pipx install black ... $ pipx list venvs are in /Users/mc/.local/pipx/venvs apps are exposed on your $PATH at /Users/mc/.local/bin package black 22.12.0, installed using Python 3.11.1 - black - blackd
运行blackd时持续出现导入错误:
$ /Users/mc/.local/bin/blackd Traceback (most recent call last): File "/Users/mc/.local/bin/blackd", line 5, in <module> from blackd import patched_main File "/Users/mc/.local/pipx/venvs/black/lib/python3.11/site-packages/blackd/__init__.py", line 14, in <module> raise ImportError( ImportError: aiohttp dependency is not installed: No module named 'aiohttp'. Please re-install black with the '[d]' extra install to obtain aiohttp_cors: `pip install black[d]`
系统Python版本为3.9.6,但pipx安装black时使用的是Python 3.11.1:
$ python3 --version Python 3.9.6
按照建议安装python@3.10后,python3版本变为3.10.9:
$ brew install python@3.10 ... ==> Pouring python@3.10--3.10.9.arm64_monterey.bottle.tar.gz ... Python has been installed as /opt/homebrew/bin/python3 Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to `python3`, `python3-config`, `pip3` etc., respectively, have been installed into /opt/homebrew/opt/python@3.10/libexec/bin ...
$ python3 --version Python 3.10.9 $ brew list python python3 ... /opt/homebrew/Cellar/python@3.10/3.10.9/bin/pip3 /opt/homebrew/Cellar/python@3.10/3.10.9/bin/pip3.10 ... /opt/homebrew/Cellar/python@3.10/3.10.9/bin/python3 /opt/homebrew/Cellar/python@3.10/3.10.9/bin/python3.10 ...
但重新安装black时仍使用Python 3.11.1,且执行pipx install black[d]时zsh提示无匹配项:
$ pipx install black[d] zsh: no matches found: black[d] $ pipx install black installed package black 22.12.0, installed using Python 3.11.1 These apps are now globally available - black - blackd done! ✨ 🌟 ✨
内容的提问来源于stack exchange,提问作者mCs
相关产品推荐
相关产品推荐

