{"id":9615,"library":"conda-pack","title":"conda-pack","description":"conda-pack is a utility for packaging conda environments, including all their dependencies, into a single relocatable archive (e.g., .tar.gz, .zip, .squashfs). This allows for easy redistribution and deployment of isolated Python environments across different systems. It's currently at version 0.9.1 and is actively maintained with a moderate release cadence, typically a few releases per year.","status":"active","version":"0.9.1","language":"en","source_language":"en","source_url":"https://github.com/conda/conda-pack","tags":["conda","environment management","packaging","distribution","relocatable environments"],"install":[{"cmd":"pip install conda-pack","lang":"bash","label":"Via pip"},{"cmd":"conda install conda-pack -c conda-forge","lang":"bash","label":"Via Conda-forge"}],"dependencies":[{"reason":"conda-pack relies on a functional conda installation (or micromamba) in the execution environment to manage and pack environments.","package":"conda","optional":false}],"imports":[{"note":"Primary function for programmatic environment packing.","symbol":"pack","correct":"from conda_pack import pack"}],"quickstart":{"code":"import os\nimport subprocess\n\n# Create a dummy environment for demonstration if it doesn't exist\nenv_name = 'my_packed_env'\nif subprocess.run(['conda', 'env', 'list'], capture_output=True, text=True).stdout.find(env_name + ' ') == -1:\n    print(f\"Creating dummy conda environment '{env_name}'...\")\n    subprocess.run(['conda', 'create', '-n', env_name, 'python=3.9', 'numpy', '-y'], check=True)\n\noutput_filename = f'{env_name}.tar.gz'\n\n# Pack the environment using the command line tool\nprint(f\"Packing environment '{env_name}' to '{output_filename}'...\")\nsubprocess.run(['conda', 'pack', '-n', env_name, '-o', output_filename, '--force'], check=True)\n\nprint(f\"Environment packed to {output_filename}\")\n\n# To unpack (demonstrative, not part of conda-pack library itself)\n# print(f\"Unpacking {output_filename} to ./unpacked_env\")\n# os.makedirs('./unpacked_env', exist_ok=True)\n# subprocess.run(['tar', '-xzf', output_filename, '-C', './unpacked_env'], check=True)\n\n# To use the Python API directly:\n# from conda_pack import pack\n# pack(name=env_name, output=output_filename, force=True)\n","lang":"python","description":"This quickstart demonstrates how to pack an existing conda environment into a tar.gz archive using the `conda pack` command-line tool. It first ensures a sample environment exists, then packs it to a specified output file. The `--force` flag overwrites the output if it already exists."},"warnings":[{"fix":"Ensure the Python environment where `conda-pack` is installed and executed is Python 3.9 or higher.","message":"conda-pack itself now requires Python 3.9 or newer. Older versions of conda-pack (0.8.0 and below) supported older Python versions (e.g., 3.7). This applies to the Python interpreter running `conda-pack`, not the Python version inside the environment being packed.","severity":"breaking","affected_versions":"0.8.1+"},{"fix":"Install Miniconda/Anaconda or Micromamba and ensure the `conda` or `micromamba` executable is in your system's PATH before running `conda-pack`.","message":"conda-pack fundamentally relies on a functional `conda` or `micromamba` installation being available in the system's PATH where it is executed. It does not bundle `conda` itself.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Pack environments on a system with the same operating system and architecture as the target deployment environment.","message":"While designed for relocatability, packed environments are generally not cross-platform or cross-architecture compatible. Packing an environment on Linux for deployment on Windows, or vice-versa, will usually fail. Similar issues can arise with different CPU architectures (e.g., x86_64 vs. ARM64).","severity":"gotcha","affected_versions":"All versions"},{"fix":"Consider using `--compress-level` for better compression (e.g., `gzip:9`, `zstd:19`), `--compressor zstd` (available since 0.8.1) for faster/better compression, or `--ignore-pip` to exclude pip-installed packages if they are not strictly necessary or can be reinstalled on target.","message":"Large environments with many packages can result in very large archive files. This can impact distribution time and storage requirements. Using compression options or ignoring specific components can help.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Install Miniconda or Anaconda, then ensure its `bin` directory (e.g., `~/miniconda3/bin`) is added to your system's PATH environment variable. Alternatively, use `micromamba`.","cause":"`conda` executable is not in the system's PATH, or Conda/Miniconda is not installed.","error":"conda: command not found"},{"fix":"Verify the environment name or path is correct using `conda env list`. If it's a new environment, create it first using `conda create -n my_env python=X.Y ...`.","cause":"The specified environment name (`-n my_env`) or prefix (`--prefix /path/to/env`) does not exist on the system where `conda-pack` is being run.","error":"CondaEnvironmentNotFoundError: Could not find conda environment: my_env"},{"fix":"If the output file already exists, add the `--force` flag to overwrite it. Check file permissions for the output directory and ensure you have write access. Check previous error messages in the console for more specific details from `conda pack`.","cause":"A generic error indicating `conda pack` failed. Often due to file existence (output file already exists) or permissions.","error":"subprocess.CalledProcessError: Command '['conda', 'pack', '-n', 'my_env', '-o', 'my_env.tar.gz']' returned non-zero exit status 1."},{"fix":"Install the library using `pip install conda-pack` or `conda install conda-pack -c conda-forge` in the active environment.","cause":"`conda-pack` is not installed in the Python environment currently being used.","error":"ModuleNotFoundError: No module named 'conda_pack'"}]}