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.
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",
...
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 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
But numpy is definitely installed, I can import it in 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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.