{"id":46996094,"url":"https://github.com/pyiron/conda_subprocess","last_synced_at":"2026-03-11T15:17:25.946Z","repository":{"id":218251227,"uuid":"745840976","full_name":"pyiron/conda_subprocess","owner":"pyiron","description":"Run a subprocess or python function in a separate conda environment.","archived":false,"fork":false,"pushed_at":"2026-03-09T20:04:30.000Z","size":343,"stargazers_count":5,"open_issues_count":9,"forks_count":1,"subscribers_count":5,"default_branch":"main","last_synced_at":"2026-03-10T01:39:28.826Z","etag":null,"topics":["conda","conda-environment","subprocess"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pyiron.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-01-20T09:59:41.000Z","updated_at":"2026-03-09T20:04:33.000Z","dependencies_parsed_at":"2024-05-15T15:51:49.449Z","dependency_job_id":"5c319662-9114-4205-bdf3-d14063edc069","html_url":"https://github.com/pyiron/conda_subprocess","commit_stats":{"total_commits":19,"total_committers":3,"mean_commits":6.333333333333333,"dds":0.368421052631579,"last_synced_commit":"fe781dea970bad985be48dd5bc843b1f3b5d1cd7"},"previous_names":["jan-janssen/conda_subprocess"],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/pyiron/conda_subprocess","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyiron%2Fconda_subprocess","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyiron%2Fconda_subprocess/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyiron%2Fconda_subprocess/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyiron%2Fconda_subprocess/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pyiron","download_url":"https://codeload.github.com/pyiron/conda_subprocess/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyiron%2Fconda_subprocess/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30385497,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-11T14:10:17.325Z","status":"ssl_error","status_checked_at":"2026-03-11T14:09:37.934Z","response_time":84,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["conda","conda-environment","subprocess"],"created_at":"2026-03-11T15:17:25.236Z","updated_at":"2026-03-11T15:17:25.927Z","avatar_url":"https://github.com/pyiron.png","language":"Python","readme":"# conda subprocess\n[![Pipeline](https://github.com/pyiron/conda_subprocess/actions/workflows/pipeline.yml/badge.svg)](https://github.com/pyiron/conda_subprocess/actions/workflows/pipeline.yml)\n[![codecov](https://codecov.io/gh/pyiron/conda_subprocess/graph/badge.svg?token=A49EEAWV9B)](https://codecov.io/gh/pyiron/conda_subprocess)\n\nRun a subprocess in a different conda environment. \n\n## Example \nCreate a new conda environment - in this example a conda environment for Python 3.12:\n```commandline\nconda create -n py312 python=3.12 \n```\n\n### Subprocess Interface\nOpen a python shell in your base environment where `conda_subprocess` is installed and execute `python --version` in the\n`py312` environment:\n```python\nfrom conda_subprocess import check_output\ncheck_output(\"python --version\", prefix_name=\"py312\")\n\u003e\u003e\u003e b'Python 3.12.1\\n'\n```\n\nAlternatively, the environment can be specified with the absolute path:\n```python\nfrom conda_subprocess import check_output\ncheck_output(\"python --version\", prefix_path=\"/Users/janssen/mambaforge/envs/py312\")\n\u003e\u003e\u003e b'Python 3.12.1\\n'\n```\n\nAs expected the process for the arguments for the subprocess call can also be defined as list:\n```python\nfrom conda_subprocess import check_output\ncheck_output([\"python\", \"--version\"], prefix_path=\"/Users/janssen/mambaforge/envs/py312\")\n\u003e\u003e\u003e b'Python 3.12.1\\n'\n```\n\nIn addition to the `check_output()` function also the `check_call()` function is implemented:\n```python\nfrom conda_subprocess import check_call\ncheck_call(\"python --version\", prefix_name=\"py312\")\n\u003e\u003e\u003e Python 3.12.1\n\u003e\u003e\u003e 0\n```\n\nAs well as the `call()` function:\n```python\nfrom conda_subprocess import call\ncall(\"python --version\", prefix_name=\"py312\")\n\u003e\u003e\u003e Python 3.12.1\n\u003e\u003e\u003e 0\n```\n\nAnd the `run()` function:\n```python\nfrom conda_subprocess import run\nrun(\"python --version\", prefix_name=\"py312\")\n\u003e\u003e\u003e Python 3.12.1\n\u003e\u003e\u003e CompletedProcess(args=['/bin/bash', '/var/folders/9p/rztyv06d0xv4h26cyv8nrw3m0000gq/T/tmpm8b8i0r3'], returncode=0)\n```\nAs the `CompletedProcess` arguments illustrate `conda_subprocess` is internally writing the commands to a temporary file\nfor execution, to guarantee the conda environment is correctly activated.\n\nFor interactive communication `conda_subprocess` implements the `Popen` interface:\n```python\nfrom subprocess import PIPE\nfrom conda_subprocess import Popen\nprocess = Popen([\"python\", \"--version\"], stdout=PIPE, prefix_name=\"py312\")\nprocess.communicate()\n\u003e\u003e\u003e (b'Python 3.12.1\\n', None)\n```\n\n### Decorator \nIn analogy to the subprocess interface the `conda_subprocess` also introduces the `@conda` decorator to \nexecute python functions in a separate conda environment:\n```python\nfrom conda_subprocess.decorator import conda\n\n@conda(prefix_name=\"py312\")\ndef add_function(parameter_1, parameter_2):\n    return parameter_1 + parameter_2\n\nadd_function(parameter_1=1, parameter_2=2)\n\u003e\u003e\u003e 3\n```\n\n## Remarks\n* The `shell` parameter and the `env` parameter are not supported in `Popen()` and all derived methods. \n* The `pipesize` parameter and the `process_group` parameter were removed for compatibility with python 3.9. \n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpyiron%2Fconda_subprocess","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpyiron%2Fconda_subprocess","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpyiron%2Fconda_subprocess/lists"}