# Conda and Miniconda

> Use CloudRepo from a conda environment: private Python packages through pip, kept apart from public ones. CloudRepo does not host conda packages.

CloudRepo hosts Python packages rather than conda packages or a conda channel. A conda user installs them with pip inside the conda environment. This page shows how to do that without letting a package from PyPI replace one of yours.

## Before you start

- A Python repository to install from and publish to. [Creating a Repository](/docs/manage/repositories.html#creating-a-repository) shows how to make one.
- A repository token that reaches it, and **Download and publish packages** access if you will publish. [Repository Tokens: Create One and Authenticate](/docs/authenticate/repository-tokens.html) shows how to mint one. pip sends the email address of the account that minted it as the username, and the token as the password.
- [conda or Miniconda](https://docs.conda.io/projects/conda/en/stable/user-guide/install/index.html), installed from conda’s own instructions.

> **Note:** Authenticate with a token.

## Install private packages into an environment

Make the environment with pip in it, activate it, and install your private packages from CloudRepo alone, in a pip step of their own. Anyone can publish a package on PyPI under your private package’s name, and a pip step that can also read PyPI may install theirs instead.

**Terminal**

```bash
conda create --name myproject python=3.12 pip
conda activate myproject
```

Write `requirements-private.txt` as in [Install private and public packages together](/docs/formats/python.html#install-private-and-public-packages-together): its first line names the CloudRepo index, and pip finds the login for the host in your `~/.netrc`, which that page also shows how to write, so the file stores no secret and can be committed. Then, with the environment active:

**Terminal**

```bash
pip install -r requirements-private.txt
```

Everything that applies to pip applies here, because the install is pip’s. Public packages go in a step of their own (`pip install -r requirements.txt`, from PyPI), nothing in that step may depend on a private package, and the public packages your private packages depend on go in `requirements.txt` too: the CloudRepo step does not look for them on PyPI, and fails if one is missing. The full rules, the three-step order and what a hash file does are on [Python Repositories](/docs/formats/python.html#install-private-and-public-packages-together). If an earlier setup put CloudRepo and PyPI together in `pip.conf`, `pip config` or `PIP_EXTRA_INDEX_URL`, remove that: every `pip install` reads such a pair as one index.

## Combine conda packages and private packages in environment.yml

conda installs the `pip:` section of `environment.yml` with a single `pip install` that covers every line in it. So keep that section for public packages, and install your private packages in the second step above, after the environment exists. Do not put the CloudRepo URL or a token in `environment.yml`:

`environment.yml`

```yaml
name: data-science-project
channels:
  - conda-forge
dependencies:
  - python=3.12
  - numpy
  - pip
  - pip:
      - requests
```

**Terminal**

```bash
conda env create --file environment.yml
conda activate data-science-project
pip install -r requirements-private.txt
```

## Publish from a conda environment

Publishing is pip’s side again: install twine in the environment and upload with it, as in [Publish Python packages to CloudRepo](/docs/publish/python.html). A wheel built inside a conda environment is an ordinary wheel, and CloudRepo stores it like any other Python file.

> **Note:** A wheel or a source distribution larger than 5 GiB (5,368,709,120 bytes) is refused with `413`, whichever environment built it.

## When pip answers 401, 403 or 404

The step that reaches CloudRepo is the `pip install -r requirements-private.txt` above, so that is where a refused token shows. pip does not print a `401` for a token it read from `~/.netrc`. It asks who you are instead:

**`User for your-org.mycloudrepo.io:`**

A revoked or expired token does this, and so does a `machine` or `login` line that does not match. With no one at the terminal to answer, as in CI, the install ends there with `EOFError: EOF when reading a line`.

The other messages are pip’s, and they mean what they mean outside conda: see [Install Python packages from CloudRepo](/docs/consume/python.html#when-pip-answers-401-403-or-404). If the CloudRepo step stops because a public package is missing, install that package in the public step first: the CloudRepo step does not look for it on PyPI.

See also [Repository tokens](/docs/authenticate/repository-tokens.html), which covers the credential each client uses, and [Python Repositories](/docs/formats/python.html), which covers pip, twine and the Python repository settings.

---

The page: https://www.cloudrepo.io/docs/formats/conda.html
