0

我下载了 Sublime text 的最新更新,没有考虑它。

但是现在当我尝试运行任何代码时,它不会导入任何模块,例如

import pandas as pd
>>>ModuleNotFoundError: No module named 'pandas'

检查版本,Sublime 使用的是 python 3.9.5,但我的 Anaconda shell 使用的是 3.7.6。

import sys
print(sys.version)
>>> 3.9.5 (tags/v3.9.5:0a7dcbd, May  3 2021, 17:27:52) [MSC v.1928 64 bit (AMD64)]

我认为这是问题所在,有什么方法可以恢复到 Anaconda 正在使用的内容(假设这是让我现有的脚本运行的阻力最小的路径)?

在网上看它有一些“Python.sublime.build”,但我并没有真正理解答案。目前我的如下所示:

{
    "cmd": ["python3", "-u", "$file"],
    "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
    "selector": "source.python",

    "env": {"PYTHONIOENCODING": "utf-8"},

    "windows": {
        "cmd": ["py", "-u", "$file"],
    },

    "variants":
    [
        {
            "name": "Syntax Check",
            "cmd": ["python3", "-m", "py_compile", "$file"],

            "windows": {
                "cmd": ["py", "-m", "py_compile", "$file"],
            }
        }
    ]
}

我的 anaconda python 文件路径是“C:\Users\NAME\anaconda3\python”,但是为上面的 python 切换它不起作用。

编辑:这是对失败的 sublime.build 文件的更改:

{
    "cmd": ["C:\\Users\\Me\\anaconda3\\python.exe", "-u", "$file"],
    "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
    "selector": "source.python",

    "env": {"PYTHONIOENCODING": "utf-8"},

    "windows": {
        "cmd": ["py", "-u", "$file"],
    },

    "variants":
    [
        {
            "name": "Syntax Check",
            "cmd": ["C:\\Users\\Me\\anaconda3\\python.exe", "-m", "py_compile", "$file"],

            "windows": {
                "cmd": ["py", "-m", "py_compile", "$file"],
            }
        }
    ]
}
4

0 回答 0