无法在Sublime Text 3中使用Ananconda解释器

时间:2019-02-28 08:22:22

标签: python python-3.x anaconda sublimetext3

我想将Sublime Text 3用作我的Python编辑器,但无法弄清楚如何将Anaconda用作Python的默认解释器。为了确保将Anaconda正确添加到路径,请在我键入的终端中

  

$哪个python

终端退货

  

/ home / rahit / anaconda3 / bin / python

但是当我在ST 3中键入这样的代码

import sys
print(sys.executable)

Sublime控制台中的输出将为

  

/ usr / bin / python

现在,如果我键入

import pandas as pd

总会有错误

  

ImportError:没有名为pandas的模块   [在0.0秒内完成,退出代码为1]   [shell_cmd:python -u“ /home/rahit/Documents/Python/pro.py”]   [dir:/ home / rahit / Documents / Python]   [路径:/ usr / local / sbin:/ usr / local / bin:/ usr / sbin:/ usr / bin:/ sbin:/ bin:/ usr / games:/> usr / local / games:/ opt / jdk -11.0.2 / bin]`

除了这些,每当我启动Sublime Text 3时,很多次我都会收到一条消息

<Anaconda.anaconda_lib.workers.local_process.LocalProcess object at 0x7f248c4eab90> process can not start a new anaconda JsonServer in the operating system because:

Anaconda无法使用您当前配置的python解释器(/ home / rahit / anaconda / bin / python)产生新进程 确保您的解释器是有效的二进制文件并且在您的PATH中,或使用指向它的绝对路径,例如:/ usr / bin / python

我已经看到有关这些主题的一些问题,但没有一个问题真正解决了我的问题。我还在GitHub上看到了类似的讨论,最后我得出结论,康达不能与ST3一起使用。最后一次,我只想知道是否有任何方法可以解决此问题,因为我真的想对Python使用ST3。

2 个答案:

答案 0 :(得分:0)

那是因为sublime使用的构建系统,它使用了默认的python可执行文件。

如果转到工具▶构建系统▶新构建系统…,然后您可以定义自己的使用anaconda可执行文件的构建系统。它应该类似于以下

{
    'cmd': ['/usr/bin/python3', '-u', '$file'],
    'file_regex': '^[ ]*File "(…*?)", line ([0-9]*)',
    'selector': 'source.python'
}

然后将路径替换为anaconda可执行文件的路径

答案 1 :(得分:0)

补充@Shadesfear的答案,要使用此自定义版本,您必须在构建代码之前选择Tools ▶ Build System ▶ AutomaticTools ▶ Build System ▶ <your-custom-build-system-name>

此外,您可以在cmd文件中用"shell_cmd": "~/anaconda3/bin/python -u $file",替换.sublime-build命令,因为它更干净并且可以使用管道。

相关问题