查找您的 Anaconda Python 解释器路径#

IDE 通常要求您指定 Python 解释器的路径。此路径因您使用的操作系统版本以及 Anaconda 或 Miniconda 版本而异,因此您需要搜索您的文件系统以找到 Python 解释器的正确路径。

您可以使用操作系统的文件管理器搜索 Python 解释器,例如 Windows 上的文件资源管理器、macOS 上的 Finder 或 Ubuntu Linux 上的 Nautilus。

您还可以使用命令行显示活动 conda 环境中 Python 解释器的位置

  1. 从“开始”菜单中,打开 Anaconda Prompt。

  2. 通过运行以下命令激活包含 Python 安装的 conda 环境

    # Replace <ENV_NAME> with the name of the environment
    conda activate <ENV_NAME>
    
  3. 通过运行以下命令找到 Python 解释器

    where python
    

这是用户 jsmith 在 Windows 10 上运行 Anaconda3 的示例命令返回

C:\Users\jsmith\Anaconda3\python.exe

# Python image in a conda environment called myenv
C:\Users\jsmith\Anaconda3\envs\myenv\python.exe
  1. 打开终端窗口。

  2. 通过运行以下命令激活包含 Python 安装的 conda 环境

    # Replace <ENV_NAME> with the name of the environment
    conda activate <ENV_NAME>
    
  3. 通过运行以下命令找到 Python 解释器

    which python
    

这是用户 jsmith 在 macOS 上运行 Anaconda 的示例命令返回

~/anaconda/bin/python

or

/Users/jsmith/anaconda/bin/python

这是用户 jsmith 在 Linux 上运行 Anaconda 的示例命令返回

~/anaconda/bin/python

or

/home/jsmith/anaconda/bin/python

注意

根据您安装的是 Anaconda 还是 Miniconda,您主目录中的文件夹可能被命名为以下名称之一

  • anaconda

  • anaconda2

  • anaconda3

  • miniconda

  • miniconda2

  • miniconda3