I'm converting a shell script to Python and I'm searching for a way to activate and deactivate a conda environment programmatically in Python. I've looked through the Conda code on Github and haven't been able to find a good solution.
I need the environment to be activated so that I can run multiple statements in it. For example:
source activate my_env
easy_install numpy
backup_db
initialize_db
source deactivate
I'm having no luck using subprocess. :-(
Reload Window from Command Palette, select base:conda as python interpreter then press Ctrl+Shift+` to open a new integrated Terminal, conda environment should be activated automatically in it.
To create a new environment for Python development using conda you can use the conda create command. For a list of all commands, take a look at Conda general commands. The command above will create a new Conda environment called “python3-env” and install the most recent version of Python.
Ctrl+Shift+P and search “Terminal”. In the Terminal window, you can see “conda activate <env>” command already executed, and the terminal is under your conda environment.
A round-a-bout way of doing it, but couldn't you have python just call the script directly?
Refer to this question on how to do that
Run a .bat file using python code
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With