First, use the command conda info --envs
to find the path of a specific environment created with conda.
$ conda info --envs
# conda environments:
#
base /Users/z/miniconda3
some-env * /Users/z/miniconda3/envs/some-env
some-other-env /Users/z/miniconda3/envs/some-other-env
For example, /Users/z/miniconda3/envs/some-env
.
Then, edit the Sublime Text project (top menu bar: Project
→ Edit Project
), and add the following in the settings
:
{
"LSP": {
"LSP-pyright": {
"enabled": true,
"settings": {
"python.pythonPath": "<conda_env_path>/bin/python"
}
}
}
}
Such as:
// See https://www.sublimetext.com/docs/projects.html
{
"folders": [
{
"path": "/Users/z/Projects/SomeFolder",
// "name": "",
"folder_exclude_patterns": [],
"file_exclude_patterns": [],
"binary_file_patterns": ["*.build", "*.build*", "*.bundle", "*.bundle*", "*.idx", "*.ipa", "*.pcm"],
"follow_symlinks": true
}
],
"settings": {
+ "LSP": {
+ "LSP-pyright": {
+ "enabled": true,
+ "settings": {
+ "python.pythonPath": "/Users/z/miniconda3/envs/some-env/bin/python"
+ }
+ }
+ },
},
}
Restart LSP-pyright
if necessary.