1
  • OS: Bigsur 11.3.1
  • Sublime text: 3.2.2
  • Sublime text extension(package): Anaconda
  • Python virtual environment management using Miniconda(Anaconda)
  • Use autoenv per each workspace directory

When I open the workspace folder and work on it in Sublime text, I usually go to the directory via Terminal(using cd) and use subl . to open it. (If I moved to the directory, its virtual environment would be activated cuz I used autoenv mentioned above)

And In the package settings(User's custom setting) of Anaconda, I can set python_interpreter, so whenever I use a function like Go to definition of the Class of 3rd party library, it reflects its installed libraries and get me there. The setting looks like this: "python_interpreter": "/Users/chois/miniconda3/envs/MY_VIRTUAL_ENV_NAME/bin/python"

But the problem is, it is set with "python_interpreter": "/Users/chois/miniconda3/bin/python" as a default, which is a (base) interpreter, not a virtual environment of the directory. So whenever I worked on that workspace, I had to manually change it.

What I tried is something like "python_interpreter": "/Users/chois/miniconda3/envs/$VIRTUAL_ENV/bin/python", but the sublime text doesn't recognize the environment variable in the package setting.

How can I flexibly set python_interpreter as each working directory's virtual environment's interpreter path, say, "/Users/chois/miniconda3/envs/$CURRENT_DIRS_VIRTUAL_ENV_NAME/bin/python"?

user3595632
  • 5,380
  • 10
  • 55
  • 111
  • 3
    Does this answer your question? [use conda environment in sublime text 3](https://stackoverflow.com/questions/34865717/use-conda-environment-in-sublime-text-3) – Roim May 22 '21 at 11:32
  • @Roim Hmm.. all solutions are not working... – user3595632 May 23 '21 at 09:35
  • Can't understand why my question is closed automatically. Mine is a different question from the one Roim mentioned.. – user3595632 May 23 '21 at 09:49
  • @user3595632 You are correct. I've reopened it for you. I'd recommend doing some research on reading external environment variables within Sublime. You may be able to write a plugin to do your task for you. – MattDMo May 24 '21 at 14:41

0 Answers0