Conda 使用 /usr/local/bin/python 而不是 conda 环境 python
Conda using /usr/local/bin/python instead of conda environment python
激活我的 conda 环境后 运行 which python
,我得到以下内容
/usr/local/bin/python
如您所见,它没有使用应该在 conda 环境中的 python,即
/Users/zeus/opt/anaconda3/envs/po/bin/python
我该如何解决这个问题?我正在使用 MacOS
这是我的conda info -a
# conda environments:
#
base /Users/zeus/opt/anaconda3
discoe /Users/zeus/opt/anaconda3/envs/discoe
po * /Users/zeus/opt/anaconda3/envs/po
py38 /Users/zeus/opt/anaconda3/envs/py38
test /Users/zeus/opt/anaconda3/envs/test
sys.version: 3.9.7 (default, Sep 16 2021, 08:50:36)
...
sys.prefix: /Users/zeus/opt/anaconda3
sys.executable: /Users/zeus/opt/anaconda3/bin/python
conda location: /Users/zeus/opt/anaconda3/lib/python3.9/site-packages/conda
conda-build: /Users/zeus/opt/anaconda3/bin/conda-build
conda-content-trust: /Users/zeus/opt/anaconda3/bin/conda-content-trust
conda-convert: /Users/zeus/opt/anaconda3/bin/conda-convert
conda-debug: /Users/zeus/opt/anaconda3/bin/conda-debug
conda-develop: /Users/zeus/opt/anaconda3/bin/conda-develop
conda-env: /Users/zeus/opt/anaconda3/bin/conda-env
conda-index: /Users/zeus/opt/anaconda3/bin/conda-index
conda-inspect: /Users/zeus/opt/anaconda3/bin/conda-inspect
conda-metapackage: /Users/zeus/opt/anaconda3/bin/conda-metapackage
conda-pack: /Users/zeus/opt/anaconda3/bin/conda-pack
conda-render: /Users/zeus/opt/anaconda3/bin/conda-render
conda-repo: /Users/zeus/opt/anaconda3/bin/conda-repo
conda-server: /Users/zeus/opt/anaconda3/bin/conda-server
conda-skeleton: /Users/zeus/opt/anaconda3/bin/conda-skeleton
conda-token: /Users/zeus/opt/anaconda3/bin/conda-token
conda-verify: /Users/zeus/opt/anaconda3/bin/conda-verify
user site dirs:
CIO_TEST: <not set>
CONDA_DEFAULT_ENV: po
CONDA_EXE: /Users/zeus/opt/anaconda3/bin/conda
CONDA_PREFIX: /Users/zeus/opt/anaconda3/envs/po
CONDA_PREFIX_1: /Users/zeus/opt/anaconda3
CONDA_PROMPT_MODIFIER: (po)
CONDA_PYTHON_EXE: /Users/zeus/opt/anaconda3/bin/python
CONDA_ROOT: /Users/zeus/opt/anaconda3
CONDA_SHLVL: 2
CURL_CA_BUNDLE: <not set>
DISCOE_PATH: /Users/zeus/Project/discoe
PATH: /Users/zeus/opt/anaconda3/bin:/Users/zeus/.poetry/bin:/Users/zeus/.nvm/versions/node/v16.13.2/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/zeus/opt/anaconda3/envs/po/bin:.:/Users/zeus/.local/bin:/Users/zeus/.local/bin
REQUESTS_CA_BUNDLE: <not set>
SSL_CERT_FILE: <not set>
这就是我的 $PATH /Users/zeus/.poetry/bin:/Users/zeus/.nvm/versions/node/v16.13.2/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/zeus/opt/anaconda3/envs/po/bin:.:/Users/zeus/.local/bin:/Users/zeus/.local/bin
我通过这个命令激活我的 conda 环境 conda activate po
这篇文章帮助我调试了这个问题。我只需要确保完全退出 conda 环境,甚至是 (base)
环境。出于某种原因,即使在我的 po
环境中停用后,它也会进入 base
环境
问题是您的 $PATH
中 anaconda3
路径之前有 /usr/local/bin
。这可能来自您的 ~/.zshrc
/~/.bashrc
/~/.profile
文件,但是正在修改 $PATH
的某处,以便 Anaconda bin
文件夹位于 /usr/local/bin
.
激活我的 conda 环境后 运行 which python
,我得到以下内容
/usr/local/bin/python
如您所见,它没有使用应该在 conda 环境中的 python,即
/Users/zeus/opt/anaconda3/envs/po/bin/python
我该如何解决这个问题?我正在使用 MacOS
这是我的conda info -a
# conda environments:
#
base /Users/zeus/opt/anaconda3
discoe /Users/zeus/opt/anaconda3/envs/discoe
po * /Users/zeus/opt/anaconda3/envs/po
py38 /Users/zeus/opt/anaconda3/envs/py38
test /Users/zeus/opt/anaconda3/envs/test
sys.version: 3.9.7 (default, Sep 16 2021, 08:50:36)
...
sys.prefix: /Users/zeus/opt/anaconda3
sys.executable: /Users/zeus/opt/anaconda3/bin/python
conda location: /Users/zeus/opt/anaconda3/lib/python3.9/site-packages/conda
conda-build: /Users/zeus/opt/anaconda3/bin/conda-build
conda-content-trust: /Users/zeus/opt/anaconda3/bin/conda-content-trust
conda-convert: /Users/zeus/opt/anaconda3/bin/conda-convert
conda-debug: /Users/zeus/opt/anaconda3/bin/conda-debug
conda-develop: /Users/zeus/opt/anaconda3/bin/conda-develop
conda-env: /Users/zeus/opt/anaconda3/bin/conda-env
conda-index: /Users/zeus/opt/anaconda3/bin/conda-index
conda-inspect: /Users/zeus/opt/anaconda3/bin/conda-inspect
conda-metapackage: /Users/zeus/opt/anaconda3/bin/conda-metapackage
conda-pack: /Users/zeus/opt/anaconda3/bin/conda-pack
conda-render: /Users/zeus/opt/anaconda3/bin/conda-render
conda-repo: /Users/zeus/opt/anaconda3/bin/conda-repo
conda-server: /Users/zeus/opt/anaconda3/bin/conda-server
conda-skeleton: /Users/zeus/opt/anaconda3/bin/conda-skeleton
conda-token: /Users/zeus/opt/anaconda3/bin/conda-token
conda-verify: /Users/zeus/opt/anaconda3/bin/conda-verify
user site dirs:
CIO_TEST: <not set>
CONDA_DEFAULT_ENV: po
CONDA_EXE: /Users/zeus/opt/anaconda3/bin/conda
CONDA_PREFIX: /Users/zeus/opt/anaconda3/envs/po
CONDA_PREFIX_1: /Users/zeus/opt/anaconda3
CONDA_PROMPT_MODIFIER: (po)
CONDA_PYTHON_EXE: /Users/zeus/opt/anaconda3/bin/python
CONDA_ROOT: /Users/zeus/opt/anaconda3
CONDA_SHLVL: 2
CURL_CA_BUNDLE: <not set>
DISCOE_PATH: /Users/zeus/Project/discoe
PATH: /Users/zeus/opt/anaconda3/bin:/Users/zeus/.poetry/bin:/Users/zeus/.nvm/versions/node/v16.13.2/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/zeus/opt/anaconda3/envs/po/bin:.:/Users/zeus/.local/bin:/Users/zeus/.local/bin
REQUESTS_CA_BUNDLE: <not set>
SSL_CERT_FILE: <not set>
这就是我的 $PATH /Users/zeus/.poetry/bin:/Users/zeus/.nvm/versions/node/v16.13.2/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/zeus/opt/anaconda3/envs/po/bin:.:/Users/zeus/.local/bin:/Users/zeus/.local/bin
我通过这个命令激活我的 conda 环境 conda activate po
这篇文章帮助我调试了这个问题。我只需要确保完全退出 conda 环境,甚至是 (base)
环境。出于某种原因,即使在我的 po
环境中停用后,它也会进入 base
环境
问题是您的 $PATH
中 anaconda3
路径之前有 /usr/local/bin
。这可能来自您的 ~/.zshrc
/~/.bashrc
/~/.profile
文件,但是正在修改 $PATH
的某处,以便 Anaconda bin
文件夹位于 /usr/local/bin
.