According to this answer you can import pip from within a Python script and use it to install a module. Is it possible to do this with conda install
?
The co
I know this question is quit old but I found that conda.cli.python_api
and conda.api
have are limited in the sense that they both don't have the option to execute commands like this:
conda export env > requirements.txt
So instead I used subprocess with the flag shell=True
to get the job done.
subprocess.run(f"conda env export --name {env} > {file_path_from_history}",shell=True)
where env
is the name of the env to be saved to requirements.txt.
Hope this helps someone.