I’m a macOS user and have Python installed via Miniconda which is basically a lightweight version of Anaconda. All of my Python development is done within conda environments. These environments have different Python packages installed based on the project that the environment is for.
For writing my Python code, I use Sublime Text 4 with the LSP-pylsp package. I launch Sublime Text from the terminal where the Python environment is already active. Sometimes things like autocompletion, displaying docstrings, and other LSP functionality work fine. But other times I don’t get any autocompletion or docstring support in Python files. So it seems like Sublime Text does not recognize certain activated conda environments. I tried the settings shown below in my .sublime-project file but it doesn’t fix my issue.
{
"python_binary": "/opt/miniconda3/envs/myproj/bin/python",
"folders":
[
{
"path": "."
}
],
"settings": {
"LSP": {
"LSP-pylsp": {
"settings": {
"pylsp.plugins.jedi.environment": "/opt/miniconda3/envs/myproj"
}
}
}
}
}
And here is my LSP-pylsp.sublime-settings file.
{
"settings": {
"pylsp.configurationSources": [
"flake8"
],
"pylsp.plugins.pycodestyle.enabled": false,
"pylsp.plugins.flake8.enabled": true,
"pylsp.plugins.flake8.maxLineLength": 120,
"pylsp.plugins.pylsp_black.enabled": true,
}
}
Is there something else I need to configure to make sure Sublime Text is using the activated conda environment? And how can I tell which conda environment it is using?