PyPI CLI Usage
PyPI CLI Usage
This page describes the CLI commands to search, install, and publish packages after creating and configuring a PyPI repository on Nexus.
Test Your Client Configuration
Use the following commands to validate client configuration before you install or publish packages:
# pip
pip install --dry-run requests --index-url http://example.nexus.com/repository/pypi-all/simple -v
# uv
uv pip install --dry-run requests --index-url http://example.nexus.com/repository/pypi-all/simple -v
# Poetry
poetry add --dry-run requests -vvv
Install and Search PyPI Packages
After you configure your client to connect to Nexus, use one of the following commands to install packages.
Install with pip
To install with pip, run the following command:
pip install <PACKAGE_NAME>
Where <PACKAGE_NAME> is the package you want to install from the configured repository.
Example:
pip install requests
To verify your configuration, run:
pip config list -v
To search available packages from the command line, run:
pip search <PACKAGE_NAME>
Where <PACKAGE_NAME> is the package name or search term.
Example:
pip search example-package
Note
pip searchis deprecated and does not work with proxy repositories. You can still search hosted repositories from the command line.For
pip-based installs, pointpipto your Nexus repository inpip.conforpip.inias described on the Configure PyPI with Nexus page.
Install with uv
To install with uv, run the following command:
uv pip install <PACKAGE_NAME>
Where <PACKAGE_NAME> is the package you want to install from the configured repository.
Example:
uv pip install requests
To sync project dependencies through the configured repository, run:
uv sync --index-url http://<NEXUS_URL>/repository/<REPO_NAME>/simple
Where,
<NEXUS_URL>- Your Nexus instance URL.<REPO_NAME>- Name of the target repository in Nexus.
Example:
uv sync --index-url http://localhost:8081/repository/pypi-all/simple
Install with Poetry
To install with poetry, run the following command:
poetry add --source <SOURCE_NAME> <PACKAGE_NAME>
Where,
<SOURCE_NAME>- Configured Poetry source name.<PACKAGE_NAME>- Package you want to add from that source.
Example:
poetry add --source nexus requests
Publish PyPI Packages
After you configure credentials, use one of the following commands to upload packages to a Nexus hosted repository.
Publish with twine
To publish with twine, run the following command:
twine upload -r <REPOSITORY_ALIAS> <FILENAME>
Where,
<REPOSITORY_ALIAS>- Repository alias defined in.pypirc.<FILENAME>- Package file you want to upload.
Example:
twine upload -r nexus-hosted dist/example_package-1.0.0.tar.gz
Publish with Poetry
Run the following commands to build the package and publish it with poetry.
poetry build
poetry publish -r <REPOSITORY_ALIAS>
Where <REPOSITORY_ALIAS> is the repository alias configured for the target hosted repository.
Example:
poetry build
poetry publish -r nexus-hosted
Publish with uv
uv can be used to install twine, then upload the package through twine.
uv pip install twine
twine upload --repository-url http://<NEXUS_URL>/repository/<REPO_NAME>/ dist/*
Where,
<NEXUS_URL>- Your Nexus instance URL.<REPO_NAME>- Target hosted repository in Nexus.
Example:
uv pip install twine
twine upload --repository-url http://localhost:8081/repository/pypi-hosted/ dist/*
Search results
No results found