Skip to content

Installing with Pip inside your pipenv project

Iván Pérez edited this page Apr 30, 2025 · 4 revisions

Managing Dependencies with Pipenv

This guide explains how to properly install and manage dependencies for the Ui-Py project using Pipenv.

Why Pipenv?

Pipenv combines pip and virtual environments into a single tool that manages dependencies in a deterministic way. It creates a Pipfile and Pipfile.lock that ensure consistent installations across different environments.

Installing Dependencies from Git

Sometimes you may need to install packages directly from GitHub or other Git repositories. Here's how to do it properly with Pipenv:

Using Pipenv (Recommended)

When installing dependencies from Git repositories, use pipenv directly to ensure they're properly tracked in your virtual environment:

# Navigate to your project directory first
cd path/to/Ui-Py

# Install a package from a Git repository
pipenv install git+https://github.com/username/repo-name@branch#egg=package-name

Example:

pipenv install git+https://github.com/Rapptz/discord-ext-menus@master#egg=discord-ext-menus

This command:

  1. Downloads the package from the Git repository
  2. Installs it in your virtual environment
  3. Updates your Pipfile and Pipfile.lock to track the dependency

Using pip (Not Recommended)

While you can use pip directly, this approach isn't recommended as it doesn't update your Pipfile:

pip install -U git+https://github.com/username/repo-name

Adding Standard Dependencies

To add regular PyPI packages to your project:

pipenv install package-name

For development dependencies (like linters or testing tools):

pipenv install --dev package-name

Updating All Dependencies

To update all dependencies to their latest versions according to your Pipfile:

pipenv update

Regenerating Pipfile.lock

If you've manually edited your Pipfile or want to ensure all dependencies are locked:

pipenv lock

Installing from Pipfile.lock

To ensure you get exactly the same versions of packages that are specified in the lock file:

pipenv sync

Exporting Requirements

If you need a requirements.txt file (for Docker builds, etc.):

pipenv requirements > requirements.txt