Skip to main content

pip install from inside your scripts

Project description

pipster 🧔‍♂️

Pipster logo
“I was `pip install`ing from the inside before it was cool”


CI/CD CI - Test and Build
Package PyPI - Version PyPI - Downloads PyPI - Python Version
Meta Hatch project linting - Ruff code style - Black types - Mypy License - MIT GitHub Sponsors

Intro

Install packages using pip from inside a python script or console:

>>> from pipster import install
>>> install('useful_package')

This tool solves the age-old problem of pip installing a package only to find that you still can't import it because it was installed for the wrong interpreter. By installing from inside python, you ensure that it will be available to import from that instance of python.

Installation

Run the following in your terminal.

$ pip install --user pipster

...and if that's not working, you can run this in a python script or console:

import subprocess
import sys
cmd = [sys.executable,  '-m', 'pip', 'install', '--user', 'pipster']
subprocess.check_call(cmd)

Usage

The install function can be called in two ways.

install('pip install useful_package')

If you give install() a single string that begins with pip install, then it will run that exact command as if it were given at the command line.

install('useful_package1', 'useful_package2', user=True, ...)

You can also pass any number of target packages along with commandline arguments or keyword arguments corresponding to commandline parameters for pip install. For example, all of the following lines have the same result:

$ pip install -r requirements.txt
>>> install('pip install -r requirements.txt')
>>> install('-r', 'requirements.txt')
>>> install(r='requirements.txt')

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pipster-0.0.5.tar.gz (209.6 kB view hashes)

Uploaded Source

Built Distribution

pipster-0.0.5-py2.py3-none-any.whl (8.2 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page