> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/artifact-registry/new-to-artifact-registry/quickstart/python-quickstart.md).

# Python

{% @harness-package-selector/package-selector platforms="%5B%7B%22label%22%3A%22Docker%22%2C%22slug%22%3A%22docker%22%2C%22path%22%3A%22artifact-registry%2Fnew-to-artifact-registry%2Fquickstart%2Fdocker-quickstart%22%7D%2C%7B%22label%22%3A%22Helm%22%2C%22slug%22%3A%22helm%22%2C%22path%22%3A%22artifact-registry%2Fnew-to-artifact-registry%2Fquickstart%2Fhelm-quickstart%22%7D%2C%7B%22label%22%3A%22Helm%20HTTP%22%2C%22slug%22%3A%22helm-http%22%2C%22path%22%3A%22artifact-registry%2Fnew-to-artifact-registry%2Fquickstart%2Fhelm-http-quickstart%22%7D%2C%7B%22label%22%3A%22Generic%22%2C%22slug%22%3A%22generic%22%2C%22path%22%3A%22artifact-registry%2Fnew-to-artifact-registry%2Fquickstart%2Fgeneric-quickstart%22%7D%2C%7B%22label%22%3A%22Raw%20File%22%2C%22slug%22%3A%22raw-file%22%2C%22path%22%3A%22artifact-registry%2Fnew-to-artifact-registry%2Fquickstart%2Fraw-file-quickstart%22%7D%2C%7B%22label%22%3A%22Maven%22%2C%22slug%22%3A%22maven%22%2C%22path%22%3A%22artifact-registry%2Fnew-to-artifact-registry%2Fquickstart%2Fmaven-quickstart%22%7D%2C%7B%22label%22%3A%22Python%22%2C%22slug%22%3A%22python%22%2C%22path%22%3A%22artifact-registry%2Fnew-to-artifact-registry%2Fquickstart%2Fpython-quickstart%22%7D%2C%7B%22label%22%3A%22NPM%22%2C%22slug%22%3A%22npm%22%2C%22path%22%3A%22artifact-registry%2Fnew-to-artifact-registry%2Fquickstart%2Fnpm-quickstart%22%7D%2C%7B%22label%22%3A%22Nuget%22%2C%22slug%22%3A%22nuget%22%2C%22path%22%3A%22artifact-registry%2Fnew-to-artifact-registry%2Fquickstart%2Fnuget-quickstart%22%7D%2C%7B%22label%22%3A%22RPM%22%2C%22slug%22%3A%22rpm%22%2C%22path%22%3A%22artifact-registry%2Fnew-to-artifact-registry%2Fquickstart%2Frpm-quickstart%22%7D%2C%7B%22label%22%3A%22Debian%22%2C%22slug%22%3A%22debian%22%2C%22path%22%3A%22artifact-registry%2Fnew-to-artifact-registry%2Fquickstart%2Fdebian-quickstart%22%7D%2C%7B%22label%22%3A%22Alpine%22%2C%22slug%22%3A%22alpine%22%2C%22path%22%3A%22artifact-registry%2Fnew-to-artifact-registry%2Fquickstart%2Falpine-quickstart%22%7D%2C%7B%22label%22%3A%22Wolfi%22%2C%22slug%22%3A%22wolfi%22%2C%22path%22%3A%22artifact-registry%2Fnew-to-artifact-registry%2Fquickstart%2Fwolfi-quickstart%22%7D%2C%7B%22label%22%3A%22Cargo%22%2C%22slug%22%3A%22cargo%22%2C%22path%22%3A%22artifact-registry%2Fnew-to-artifact-registry%2Fquickstart%2Fcargo-quickstart%22%7D%2C%7B%22label%22%3A%22Conan%22%2C%22slug%22%3A%22conan%22%2C%22path%22%3A%22artifact-registry%2Fnew-to-artifact-registry%2Fquickstart%2Fconan-quickstart%22%7D%2C%7B%22label%22%3A%22Go%22%2C%22slug%22%3A%22go%22%2C%22path%22%3A%22artifact-registry%2Fnew-to-artifact-registry%2Fquickstart%2Fgo-quickstart%22%7D%2C%7B%22label%22%3A%22Hugging%20Face%22%2C%22slug%22%3A%22hugging-face%22%2C%22path%22%3A%22artifact-registry%2Fnew-to-artifact-registry%2Fquickstart%2Fhugging-face-quickstart%22%7D%2C%7B%22label%22%3A%22Conda%22%2C%22slug%22%3A%22conda%22%2C%22path%22%3A%22artifact-registry%2Fnew-to-artifact-registry%2Fquickstart%2Fconda-quickstart%22%7D%2C%7B%22label%22%3A%22Dart%22%2C%22slug%22%3A%22dart%22%2C%22path%22%3A%22artifact-registry%2Fnew-to-artifact-registry%2Fquickstart%2Fdart-quickstart%22%7D%2C%7B%22label%22%3A%22PHP%20Composer%22%2C%22slug%22%3A%22php-composer%22%2C%22path%22%3A%22artifact-registry%2Fnew-to-artifact-registry%2Fquickstart%2Fphp-composer-quickstart%22%7D%2C%7B%22label%22%3A%22Swift%22%2C%22slug%22%3A%22swift%22%2C%22path%22%3A%22artifact-registry%2Fnew-to-artifact-registry%2Fquickstart%2Fswift-quickstart%22%7D%2C%7B%22label%22%3A%22Puppet%22%2C%22slug%22%3A%22puppet%22%2C%22path%22%3A%22artifact-registry%2Fnew-to-artifact-registry%2Fquickstart%2Fpuppet-quickstart%22%7D%2C%7B%22label%22%3A%22Terraform%22%2C%22slug%22%3A%22terraform%22%2C%22path%22%3A%22artifact-registry%2Fnew-to-artifact-registry%2Fquickstart%2Fterraform-quickstart%22%7D%2C%7B%22label%22%3A%22R%20(CRAN)%22%2C%22slug%22%3A%22r-cran%22%2C%22path%22%3A%22artifact-registry%2Fnew-to-artifact-registry%2Fquickstart%2Fr-cran-quickstart%22%7D%2C%7B%22label%22%3A%22RubyGems%22%2C%22slug%22%3A%22rubygems%22%2C%22path%22%3A%22artifact-registry%2Fnew-to-artifact-registry%2Fquickstart%2Frubygems-quickstart%22%7D%5D" selectedPlatform="python" %}

### Prerequisites <a href="#prerequisites" id="prerequisites"></a>

* Ensure you have **Python CLI** installed and configured on your local machine.
* Ensure you have access to a Harness account with the appropriate permissions to create registries and connectors.

***

### Create a Python Artifact Registry <a href="#create-a-python-artifact-registry" id="create-a-python-artifact-registry"></a>

{% tabs %}
{% tab title="Interactive Guide" %}
{% embed url="<https://app.tango.us/app/embed/6f8a320c-43f9-4456-9b4c-662a823151a6?skipCover=false&defaultListView=false&skipBranding=false&makeViewOnly=true&hideAuthorAndDetails=true>" %}
Create a Python Artifact Registry in Harness
{% endembed %}
{% endtab %}

{% tab title="Step-by-Step" %}

1. Navigate to the Artifact Registry module in your Harness project.
2. Click on **New Artifact Registry**.
3. In the Registry Type list, select **Python Registry**.
4. Provide a Registry Name.
   * The registry name must start with a letter and can include lowercase alphanumeric characters, underscores (`_`), periods (`.`), and hyphens (`-`).
5. Optionally, add a Description and Labels for better organization.
6. Choose visibility between **Public** and **Private**.
7. Click **Create Registry** to finalize.
   {% endtab %}
   {% endtabs %}

{% hint style="info" %}
**PRIVATE PYTHON REGISTRY**

This registry will serve as your private Python registry within Harness.
{% endhint %}

***

### Configure an Upstream Proxy (Optional) <a href="#configure-an-upstream-proxy-optional" id="configure-an-upstream-proxy-optional"></a>

An upstream proxy allows your registry to fetch Python packages from external sources if they are not available locally.

{% tabs %}
{% tab title="Interactive Guides" %}

#### Create an upstream proxy

{% embed url="<https://app.tango.us/app/embed/c024c25d-4d6b-40d2-a8b5-903a7168b2af?skipCover=false&defaultListView=false&skipBranding=false&makeViewOnly=true&hideAuthorAndDetails=true>" %}
Create a Python Upstream Proxy in Harness
{% endembed %}

#### Configure the upstream proxy in your registry

{% embed url="<https://app.tango.us/app/embed/bdc8b67c-b956-4a4f-8b46-7873720c7c78?skipCover=false&defaultListView=false&skipBranding=false&makeViewOnly=true&hideAuthorAndDetails=true>" %}
Configure your Python Upstream Proxy in Harness
{% endembed %}
{% endtab %}

{% tab title="Step-by-Step" %}

#### Create an upstream proxy

1\. In the Artifact Registry module, click the dropdown next to \*\*New Artifact Registry\*\* and select \*\*Upstream Proxy\*\*. 2. Choose \*\*Python Registry\*\* as the proxy type. 3. Click \*\*Create Proxy\*\* to establish the connection.

#### Configure the upstream proxy in your registry

1\. In the Artifact Registry module, select an existing Artifact Registry. 2. Select the \*\*Configuration\*\* tab. 3. Under \*\*Advanced (Optional)\*\*, select \*\*Configure Upstream\*\*. 4. Select from the list of compatible proxies to add them to your registry. 5. Click \*\*Save\*\* to save the configuration.
{% endtab %}
{% endtabs %}

{% hint style="info" %}
**UPSTREAM PROXY CACHING**

If a Python package isn’t found in your Harness registry, the upstream proxy fetches it from an external registry like PyPI, reducing duplication and improving package resolution.
{% endhint %}

#### Configuring Python PyPI Upstream Proxy with Custom Registry Suffix <a href="#configuring-python-pypi-upstream-proxy-with-custom-registry-suffix" id="configuring-python-pypi-upstream-proxy-with-custom-registry-suffix"></a>

Harness supports configuring Python PyPI upstream proxies for registries that use non-standard endpoint paths. In addition to specifying the remote registry URL, you can define an optional custom registry suffix when the PyPI repository is not available under the default `/simple/` endpoint.

![](/files/mH1sR176v2Gsx87x58hl)

This is commonly required when integrating with enterprise artifact repositories such as Artifactory, Nexus, or private PyPI mirrors. Authentication can be configured using anonymous access or username and password credentials. Once configured, Harness handles package resolution and authentication automatically when proxying Python dependencies from the upstream registry.

***

### Publish & Install Python Packages <a href="#publish-and-install-python-packages" id="publish-and-install-python-packages"></a>

{% tabs %}
{% tab title="pip" %}
**1. Generate Identity Token**

An identity token will serve as the password for uploading and downloading artifacts.

Generate an identity token from your Harness account settings.

**2. Configure Authentication**

Create or update your `~/.pypirc` file with the following content:

```ini
[distutils]
index-servers = harness

[harness]
repository = https://pkg.harness.io/pkg/<account-id>/<python-registry-name>/python
username = <your-email@harness.io>
password = <identity-token>
```

**3. Publish Package**

Build and publish your package:

```bash
python -m build
```

```bash
python -m twine upload --repository harness /path/to/files/*
```

**4. Install Package**

Install a package using pip:

```bash
pip install --index-url https://<your-email@harness.io>:<TOKEN>@pkg.harness.io/pkg/<account-id>/<python-registry-name>/python/simple --no-deps <ARTIFACT_NAME>==<VERSION>
```

{% endtab %}

{% tab title="poetry" %}
**1. Generate Identity Token**

An identity token will serve as the password for uploading and downloading artifacts.

Generate an identity token from your Harness account settings.

**2. Configure Repository**

Add the registry as a source and configure authentication:

```bash
poetry source add --priority=explicit harness https://<your-email@harness.io>:<TOKEN>@pkg.harness.io/pkg/<account-id>/<python-registry-name>/python/simple/
```

```bash
poetry config http-basic.harness <your-email@harness.io> <identity-token>
```

**3. Publish Package**

Configure publish repository and publish your package:

```bash
poetry config repositories.harness https://pkg.harness.io/pkg/<account-id>/<python-registry-name>/python
```

```bash
poetry build
```

```bash
poetry publish --repository harness
```

**4. Install Package**

Install a package using poetry:

```bash
poetry add --source harness <ARTIFACT_NAME>==<VERSION>
```

{% endtab %}

{% tab title="uv" %}
**1. Generate Identity Token**

An identity token will serve as the password for uploading and downloading artifacts.

Generate an identity token from your Harness account settings.

**2. Publish Package**

Build and publish your package:

```bash
uv build
```

```bash
uv publish --publish-url https://pkg.harness.io/pkg/<account-id>/<python-registry-name>/python --username <your-email@harness.io> --password <identity-token>
```

**3. Install Package**

Install a package using uv:

```bash
uv pip install --index-url https://<your-email@harness.io>:<TOKEN>@pkg.harness.io/pkg/<account-id>/<python-registry-name>/python/simple --no-deps <ARTIFACT_NAME>==<VERSION>
```

{% endtab %}
{% endtabs %}

***
