TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/conda/conda/llms.txt
Use this file to discover all available pages before exploring further.
conda package command provides low-level tools for creating conda packages. This command is useful for package development, debugging package installations, and creating custom packages from untracked files in an environment.
Syntax
Options
-w, --which PATH [PATH ...]
Given one or more file paths, print which conda package each file came from.
-u, --untracked
Display all untracked files in the environment and exit. Untracked files are files that exist in the environment but are not part of any installed conda package.
-r, --reset
Remove all untracked files from the environment and exit. This is useful for cleaning up an environment to return it to a pristine state.
--pkg-name NAME
Designate the package name for the package being created. Defaults to "unknown".
--pkg-version VERSION
Designate the package version for the package being created. Defaults to "0.0".
--pkg-build BUILD
Designate the build number for the package being created. Defaults to 0.
-n, --name NAME
Name of the environment to operate on.
-p, --prefix PREFIX
Full path to the environment prefix.
Common Use Cases
Find which package a file belongs to
Determine which conda package installed a specific file:- Debugging file conflicts
- Understanding package contents
- Tracking down the source of a binary or library
Identify untracked files
See what files exist in your environment that weren’t installed by conda:- Custom scripts you’ve added
- Configuration files
- Build artifacts
- Files from pip installations
Clean up an environment
Remove all untracked files to restore an environment to its original state:Create a custom package
Create a conda package from untracked files in your environment:How Package Creation Works
When creating a package:- File Collection: Conda identifies all untracked files in the environment
- Metadata Generation: Creates package metadata including:
- Package name, version, and build number
- Platform and architecture information
- File list and checksums
- Python dependencies (if files are in site-packages)
- Shebang Fixing: For scripts in
bin/, replaces hardcoded paths with conda’s prefix placeholder - Archive Creation: Bundles files and metadata into a
.tar.bz2archive
Determining Package Origin
The--which flag works by:
- Resolving the absolute path of the file
- Finding the conda environment prefix containing the file
- Checking the
conda-meta/directory for package records - Matching the file path against each package’s file list
The
--which flag only finds packages for files installed by conda. Files installed by pip or manually added will not be found.Advanced Usage
Create a package with Python dependencies
If your untracked files include Python modules insite-packages/, conda automatically:
- Detects the installed Python version
- Adds Python as a dependency
- Includes the Python version in the build string
my_python_pkg-2.1.0-py39_0.tar.bz2 (for Python 3.9)
Query multiple files at once
Use in scripts
The--which flag is useful in automation scripts: