I downloaded and installed Anaconda 2 from Anaconda Home. I registered Anaconda as my default Python 2, but I didn't add it to my PATH. After this, I started the Anaconda Prompt and everything was OK.
Now I want to use Anaconda with Sublime Text 3. After doing some search, I installed the Anaconda plugin by Package Control. After that, I changed Anaconda's Default Setting like:
...
"python_interpreter": "E:\\Programs\\Anaconda2\\python.exe",
...
And User Setting like:
{
"python_interpreter": "E:\\Programs\\Anaconda2\\python.exe",
"swallow_startup_errors": true,
"anaconda_linting": false,
}
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"
However, it prints out
'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' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
These Chinese words means cmd can't find an appropriate Python.exe. It seems that I haven't chosen my Python interpreter. However, I definitely set that in python_interpreter
.
So I use the 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
But NumPy is definitely installed. I can import it in the Anaconda Prompt.
So how can I solve all this problem and use Ctrl + B to run my Python code in Sublime Text 3?
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 System
and enter the following json input
{
"cmd": ["C:\\Users\\<<YOUR_NAME>>\\Anaconda3\\python.exe", "$file"],
"selector": "source.python",
"file_regex": "^\\s*File \"(...*?)\", line ([0-9]*)"
}
You can replace the path with the path you have stored your python interpreter for anaconda.
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.
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.