conda subprocess
Run a subprocess in a different conda environment.
Installation
conda_subprocess is available on PyPI and
conda-forge:
pip install conda_subprocess
or
conda install -c conda-forge conda_subprocess
The @conda decorator additionally requires executorlib, which can be
installed via the executorlib extra:
pip install conda_subprocess[executorlib]
A working conda (or mamba) installation is required at runtime - conda_subprocess locates it via the
CONDA_EXE environment variable, which is set automatically inside an activated conda environment.
Example
Create a new conda environment - in this example a conda environment for Python 3.12:
conda create -n py312 python=3.12
Subprocess Interface
conda_subprocess mirrors the subprocess module
(call(), check_call(), check_output(), run(), Popen()) and adds two keyword arguments to all of them
to select the target environment:
prefix_name- the name of the target conda environment, e.g."py312"prefix_path- the absolute path of the target conda environment, e.g."/home/user/mambaforge/envs/py312"
If neither is given, the currently active conda environment is used, just like with a plain subprocess call.
Open a python shell in your base environment where conda_subprocess is installed and execute python --version in the
py312 environment:
from conda_subprocess import check_output
check_output("python --version", prefix_name="py312")
>>> b'Python 3.12.1\n'
Alternatively, the environment can be specified with the absolute path:
from conda_subprocess import check_output
check_output("python --version", prefix_path="/Users/janssen/mambaforge/envs/py312")
>>> b'Python 3.12.1\n'
As expected the process for the arguments for the subprocess call can also be defined as list:
from conda_subprocess import check_output
check_output(["python", "--version"], prefix_path="/Users/janssen/mambaforge/envs/py312")
>>> b'Python 3.12.1\n'
In addition to the check_output() function also the check_call() function is implemented:
from conda_subprocess import check_call
check_call("python --version", prefix_name="py312")
>>> Python 3.12.1
>>> 0
As well as the call() function:
from conda_subprocess import call
call("python --version", prefix_name="py312")
>>> Python 3.12.1
>>> 0
And the run() function:
from conda_subprocess import run
run("python --version", prefix_name="py312")
>>> Python 3.12.1
>>> CompletedProcess(args=['/bin/bash', '/var/folders/9p/rztyv06d0xv4h26cyv8nrw3m0000gq/T/tmpm8b8i0r3'], returncode=0)
As the CompletedProcess arguments illustrate conda_subprocess is internally writing the commands to a temporary file
for execution, to guarantee the conda environment is correctly activated.
For interactive communication conda_subprocess implements the Popen interface:
from subprocess import PIPE
from conda_subprocess import Popen
process = Popen(["python", "--version"], stdout=PIPE, prefix_name="py312")
process.communicate()
>>> (b'Python 3.12.1\n', None)
Decorator
In analogy to the subprocess interface the conda_subprocess also introduces the @conda decorator to
execute python functions in a separate conda environment:
from conda_subprocess.decorator import conda
@conda(prefix_name="py312")
def add_function(parameter_1, parameter_2):
return parameter_1 + parameter_2
add_function(parameter_1=1, parameter_2=2)
>>> 3
Remarks
- The
shellparameter and theenvparameter are not supported inPopen()and all derived methods. - The
pipesizeparameter and theprocess_groupparameter were removed for compatibility with python 3.9.
Documentation
Metadata
Release files for conda-subprocess 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| conda_subprocess-0.1.0.tar.gz | 10.9 kB | With provenance | Details for conda_subprocess-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| conda_subprocess-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for conda_subprocess-0.1.0-py3-none-any.whl |
Total release size: 22.4 kB
Release files / conda_subprocess-0.1.0.tar.gz
| Download URL | conda_subprocess-0.1.0.tar.gz |
|---|---|
| Size | 10.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f3b34f22704d6cb7c43a87817d12c69607d89049a41382de5f04559a92c54e7c
|
|
BLAKE2b-256 checksum How to use checksums |
4e09861374c263ec3c1a37bb58d699b2a82ac33172667c977fc2e9821d35e843
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.
Transparency logRelease files / conda_subprocess-0.1.0-py3-none-any.whl
| Download URL | conda_subprocess-0.1.0-py3-none-any.whl |
|---|---|
| Size | 11.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5e902f897506454186ef21eb69bece901354618865e1c3ab025c3a1fe4a6fa27
|
|
BLAKE2b-256 checksum How to use checksums |
9675169dd96de864fa4e209837fe4444ea8725f1443e2160a38532211180dcda
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.
Transparency logSecurity for conda-subprocess 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for conda_subprocess-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.