本文介绍了如何为Anaconda配置Sublime Text 3?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从 Anaconda Home 下载并安装Anaconda2.我将Anaconda注册为我的默认Python2,但没有添加到我的PATH中.之后,我启动Anaconda Prompt,一切正常.

I download and install Anaconda2 from Anaconda Home. I registered Anaconda as my default Python2, but didn't add to my PATH. After this, I start Anaconda Prompt and everything is OK.

现在,我想将Anaconda与Sublime Text 3一起使用.进行一些搜索之后,我通过Package Control安装了Anaconda插件.之后,我将Anaconda的默认设置更改为

Now I want to use Anaconda with Sublime Text 3. After doing some search, I install the Anaconda plugin by Package Control. After that, I change Anaconda's Default Setting like

...
"python_interpreter": "E:\\Programs\\Anaconda2\\python.exe",
...

和用户设置,例如

{
    "python_interpreter": "E:\\Programs\\Anaconda2\\python.exe",
    "swallow_startup_errors": true,
    "anaconda_linting": false,
}

根据我的期望,当我按ctrl + B时​​,以下代码将正常打印

According to my expectations, the following codes will print normally when I press ctrl+B

import numpy as np
import pandas as pd

import sys
print "hello"

但是它会打印出来

'python' �����ڲ����ⲿ���Ҳ���ǿ����еij���
���������ļ���

我不知道这到底意味着什么,所以我在控制台中运行它并打印

I don't know what it exactly means so I run it in console, and it prints

>python F:/LOL/test.py
'python' 不是内部或外部命令,也不是可运行的程序
或批处理文件。

这些中文单词表示cmd找不到合适的Python.exe.似乎我没有选择我的python解释器,但是我确实在python_interpreter中设置了它.

These chinese words means cmd can't find a appropriate Python.exe. It seems that I haven't choose my python interpreter, however I definitely set that in python_interpreter.

所以我使用完整路径,并且现在可以打印出

So I use full path, and it now prints out

>E:\Programs\Anaconda2\pkgs\python-2.7.16-hcb6e200_0\python.exe 
F:/LOL/test.py
Traceback (most recent call last):
  File "F:/LOL/test.py", line 1, in <module>
    import numpy as np
ImportError: No module named numpy

但是肯定安装了numpy,我可以将其导入到Anaconda Prompt中.

But numpy is definitely installed, I can import it in Anaconda Prompt.

那么我该如何解决所有这些问题,并使用ctrl + B在Sublime Text 3中运行我的python代码.

So How can I solve all this problem and use ctrl+B to run my python code in Sublime Text 3.

推荐答案

似乎您的蟒蛇提示使用了错误的构建系统.您只需转到Tools-> Build Systems-> New Build System,即可添加构建系统然后输入以下json输入

It appears that you are using the wrong build system for your anaconda prompt. You can simply add in a build system by going to Tools->Build Systems->New Build Systemand enter the following json input

{
    "cmd": ["C:\\Users\\<<YOUR_NAME>>\\Anaconda3\\python.exe", "$file"],
    "selector": "source.python",
    "file_regex": "^\\s*File \"(...*?)\", line ([0-9]*)"
}

您可以将路径替换为您为anaconda存储的python解释器的路径.

You can replace the path with the path you have stored your python interpreter for anaconda.

sublime-build文件应以.sublime-build扩展名保存在\AppData\Roaming\Sublime Text 3\Packages\User中,并带有您想要的名称.

The sublime-build file should be saved in \AppData\Roaming\Sublime Text 3\Packages\User with a .sublime-build extension with whatever name you want it to be.

然后可以通过Tools-> Build Systems-> anaconda访问它.这应该将升华指向正确的解释器.然后,您可以使用以下命令pip install --upgrade --force-reinstall numpy

You can then access it by Tools->Build Systems-> anaconda. This should point sublime to the correct interpreter. You can then force uninstall and reinstall numpy using the following command pip install --upgrade --force-reinstall numpy

我希望这能解决您的问题.

I hope this solves your issue.

这篇关于如何为Anaconda配置Sublime Text 3?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 07:45