{"id":8760,"library":"venv-pack","title":"venv-pack for Packaging Python Virtual Environments","description":"venv-pack (version 0.2.0) is a utility that packages Python virtual environments into a `.tar.gz` archive for easy redistribution. It aims to make deploying Python applications with their dependencies straightforward by creating a self-contained, relocatable environment. Releases are infrequent, with the last major update (0.2.0) released in August 2023.","status":"active","version":"0.2.0","language":"en","source_language":"en","source_url":"https://github.com/conda-incubator/venv-pack","tags":["virtual environment","packaging","distribution","deployment","archive"],"install":[{"cmd":"pip install venv-pack","lang":"bash","label":"Install `venv-pack`"}],"dependencies":[],"imports":[{"note":"While primarily a command-line tool, this function offers programmatic access to package an environment from Python code. Most users interact via the `venv-pack` command-line interface.","symbol":"pack_venv_environment","correct":"from venv_pack import pack_venv_environment"}],"quickstart":{"code":"python3 -m venv my_app_env\nsource my_app_env/bin/activate\npip install requests\ndeactivate\nvenv-pack -o my_app_env.tar.gz my_app_env\nls -lh my_app_env.tar.gz","lang":"bash","description":"This quickstart demonstrates how to create a virtual environment, install a package into it, and then use `venv-pack` to compress it into a redistributable .tar.gz archive. The `venv-pack` command should ideally be run from outside the activated environment."},"warnings":[{"fix":"Ensure target and source environments have compatible OS/architecture, or rely only on pure Python packages for maximum portability. `venv-pack` itself cannot solve fundamental binary compatibility issues.","message":"Packed environments might not be universally portable across different operating systems or CPU architectures due to compiled dependencies. Always test on target systems.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always run `venv-pack` from *outside* the target virtual environment, specifying the environment's path as an argument (e.g., `venv-pack -o output.tar.gz my_env`).","message":"Running `venv-pack` from *within* the virtual environment it is trying to pack can lead to unexpected behavior, such as `venv-pack` itself being included in the archive, increasing its size, or potential issues with environment state.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure the target system has a compatible Python interpreter available at a standard path. While `venv-pack` attempts to make paths relative where possible, certain custom setups may require manual adjustment post-unpacking.","message":"If your virtual environment is non-standard (e.g., a custom Python executable path), the packed environment might fail to activate or run correctly on the target system.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Install it using `pip install venv-pack`. If already installed, ensure your shell environment's PATH includes the directory where pip installs executables.","cause":"`venv-pack` is not installed, or its installation directory (e.g., `~/.local/bin`) is not included in your system's PATH environment variable.","error":"venv-pack: command not found"},{"fix":"Verify the path to your virtual environment (e.g., `my_env`) is correct and that it was created using standard methods like `python -m venv` or `virtualenv`.","cause":"The directory provided to `venv-pack` does not appear to be a valid Python virtual environment, or the path is incorrect.","error":"Error: The specified path 'my_env' is not a virtual environment."},{"fix":"Double-check the spelling and existence of the virtual environment directory you are trying to pack.","cause":"The input path to the virtual environment does not exist.","error":"FileNotFoundError: [Errno 2] No such file or directory: 'my_env'"},{"fix":"Run the command from a directory where you have write permissions, or specify an output path to a writable location (e.g., `venv-pack -o /tmp/my_app_env.tar.gz my_app_env`).","cause":"You do not have write permissions in the directory where `venv-pack` is trying to create the output archive.","error":"PermissionError: [Errno 13] Permission denied: 'output.tar.gz'"}]}