Python-配置PyCharm使用正确的Python解释器

方法一:使用系统Python解释器

  1. 打开PyCharm

  2. 进入 File → Settings → Project → Python Interpreter

  3. 点击右侧的 Add Interpreter,选择 Add Local Interpreter

  4. 选择 System Interpreter

  5. 在解释器路径中,选择你安装PyTorch时使用的Python解释器

    • 通常路径如:C:\Users\用户名\AppData\Local\Programs\Python\PythonXX\python.exe

    • 或Anaconda路径:C:\Users\用户名\anaconda3\python.exe

方法二:使用现有虚拟环境

如果你在虚拟环境中安装了PyTorch:

  1. 在 Add Python Interpreter 窗口中选择 Existing environment

  2. 找到虚拟环境的Python解释器,通常在:

    • C:\Users\用户名\venv\Scripts\python.exe(venv)

    • C:\Users\用户名\anaconda3\envs\环境名\python.exe(conda)

posted @ 2025-10-22 14:21  业余砖家  阅读(271)  评论(0)    收藏  举报