conda环境在anaconda prompt中正常使用,sublime中通过tools->build system->new build system的方式将conda环境添加进去时,使用的时候会报一大堆错。
原因:使用前需要先激活环境
解决方案:
Step 1. Follow these instructions. https://docs.anaconda.com/anaconda/user-guide/tasks/integration/sublime/
Step 2. Press Ctrl+Shift+P and select Conda:Activate Environment.
Step 3. Import numpy and cry from happiness.
注意:
默认的conda目录可能与自己的目录不同,此时需要进行修改:
- 菜单栏选择 Tools -> Build System -> Conda
- 菜单栏依次选择Preferences -> Package Settings -> Conda -> Setting-User ,输入如下配置:
-
// Default settings for sublime-text-conda: { // executable is the path to anaconda's python // this python executable is used in order to find conda //"executable": "~/anaconda3/bin/python3", "executable": "E:/Anaconda3/python", // Directory in which the conda envs are stored // Default location is the user's home directory //"environment_directory": "~/anaconda3/envs/", "environment_directory": "E:/Anaconda3/envs/", // configuration is the path to conda's configuration file "configuration": "~/.condarc" }
其中
"executable"
和"environment_directory"
按自己实际anaconda3安装路径配置
修改完成后执行第二步就可以了!
下次需要使用conda环境时,
先把Tools->Build System改为Conda
Ctrl+Shift+P->Conda 点击Activate Environment,选择需要的环境即可。