Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
224 views
in Technique[技术] by (71.8m points)

python - use conda environment in sublime text 3

Using Sublime Text 3, how can I build a python file using a conda environment that I've created as in http://conda.pydata.org/docs/using/envs.html

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

NOTE: This will work for virtual environments created with conda as well as venv or virtualenv, you just need to activate it first to find the path to the python[3] executable.

A standard Python .sublime-build file looks like this:

{
    "cmd": ["/path/to/python", "-u", "$file"],
    "file_regex": "^[ ]*File "(...*?)", line ([0-9]*)",
    "selector": "source.python"
}

All you need to do to use a particular conda environment is modify the path to the python or python3 executable within the environment. To find it, activate your environment and type (depending on the version you're using)

which python

or

which python3

on Linux/macOS, or

where python

on Windows, then copy the path into your custom .sublime-build file. Save the file in your Packages/User directory, then make sure you pick the right one via Tools -> Build System before building.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...