无法在 VSC 中使用 asdf 定位 pip 包

问题描述

我刚刚安装了新安装的 BigSur 和 Python(使用 asdf),在安装它们似乎最终出现的 pip 包时:

./.asdf/installs/python/3.9.2/lib/python3.9/site-packages

例如,当输入 which Flake8 时,我得到 Flake8 not found,但是当我再次安装它时 pip install Flake8,我得到以下信息:

> which Flake8
Flake8 not found

~
> pip install Flake8
Requirement already satisfied: Flake8 in ./.asdf/installs/python/3.9.2/lib/python3.9/site-packages (3.8.4)
Requirement already satisfied: pycodestyle<2.7.0,>=2.6.0a1 in ./.asdf/installs/python/3.9.2/lib/python3.9/site-packages (from Flake8) (2.6.0)
Requirement already satisfied: mccabe<0.7.0,>=0.6.0 in ./.asdf/installs/python/3.9.2/lib/python3.9/site-packages (from Flake8) (0.6.1)
Requirement already satisfied: pyflakes<2.3.0,>=2.2.0 in ./.asdf/installs/python/3.9.2/lib/python3.9/site-packages (from Flake8) (2.2.0)

我刚刚尝试使用像 pip install requests 一样安装的请求,但在使用 which 时也没有找到,但我设法在 VSC 中使用了该软件包。

我正在使用 Flake8 和 Black,我需要为 VSC 提供路径。我用过

./.asdf/installs/python/3.9.2/lib/python3.9/site-packages/<package name>

但 VSC 似乎并没有解决这个问题。我使用的是最新版本。

> python -V
Python 3.9.2

~
> pip -V
pip 21.0.1 from /Users/paul/.asdf/installs/python/3.9.2/lib/python3.9/site-packages/pip (python 3.9)

这也可能有帮助:

~
> which python
/Users/paul/.asdf/shims/python

~
> which pip
/Users/paul/.asdf/shims/pip

知道如何让 which 显示正确的路径,以便我的列表和格式正常工作吗?

解决方法

这修复了它...https://til.hashrocket.com/posts/ques11vrjs-get-pip-installed-executables-into-the-asdf-path

asdf reshim python

我很好奇为什么我必须这样做...如果有人能回答