This project has been archived by its maintainers, and is no longer receiving any updates.
pipster: The pythonic way to pip install
Intro
Install packages using pip from inside a python script or console:
>>> import pipster
>>> pipster.install("some_package")
- Simple, fool-proof installation method for learners
- No command-line access or skills needed.
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.
We recommend using pipster.install() either in a separate python script or an
interactive REPL. If using an interactive REPL, we recommend restarting
python after installation.
Note: The developers of pipster hope that this tool will eventually be
integrated into pip so that this functionality becomes ubiquitous. However,
first pipster needs to be extensively tested and used in real life. By
sharing this tool with others, and reporting bugs/issues if they arise, you are
helping us achieve that goal.
Installation
To install pipster, run the following in your terminal (you may need to
replace python with the name of the executable you use to run Python, such as
python3, python3.11, etc.):
$ python -m pip install 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", "pipster"]
subprocess.check_call(cmd)
Usage
The install() function can be called in two ways.
1. Copy-paste pip install ...
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("pip install some_package")`
install("pip install --user --upgrade pkg1 pkg2 pkg3")
2. Python function API
You can also pass any number of target packages along with keyword arguments
corresponding to command-line options for pip install. Note that the python
keyword arguments use _ instead of -.
The pipster.install() function does not validate which options are available
in the command line. If you give it arguments that are not valid command-line
options, then it will attempt to run pip install with those options, and
pip will return an error.
The CLI options
reference
shows every possible command-line option and its corresponding expression as a
keyword argument for install(). The keyword arguments are also shown in the
docstring, which can be seen by running help(install) (type q to exit). The
principles used to convert command-line options to python keyword arguments are
layed out in the following sections.
Boolean options
Most boolean command-line options are set by giving <option>=True.
install("pkg", user=True) # pip install --user pkg
install("pkg", "pkg2", upgrade=True) # pip install --upgrade pkg pkg2
Boolean command-line options that begin with --no-, such as --no-color are
set by removing the no- prefix and using <option>=False.
install("pkg", color=False) # pip install --no-color pkg
install("pkg", deps=False) # pip install --no-deps pkg
Key-value options
Usually, key-value options are set using a string: <option>="<value>".
install(r="requirements.txt") # pip install -r requirements.txt
install("pkg", python_version="3.8") # pip install --python-version 3.8 pkg
However, some key-value options can be used multiple times. In these cases,
the value given should be a list of strings: <option>=["<val1>", "<val2>"].
install(r=["reqs1.txt", "reqs2.txt"]) # pip install -r reqs1.txt -r reqs2.txt
Additive options
Some command-line options are additive (notably -q and -v), and can be used
up to 3 times. These can be set using either an integer or True.
install('pkg', v=True) # pip install -v pkg
install('pkg', v=1) # pip install -v pkg
install('pkg', v=2) # pip install -vv pkg
install('pkg', v=3) # pip install -vvv pkg
Omitting options
Any option that is assigned the value None is omitted from the command. This
feature facilitates simpler logic in preparing keyword arguments
programmatically.
user = None
if <logical test>:
user = True
install('pkg', user=user)
Installing modules that were already imported
If you re-install, upgrade, or downgrade a package after it has already been
imported, pipster will do its best to detect this and issue a warning that
Python should be restarted for changes to be available.
>>> import pipster
>>> import requests
>>> requests.__version__
'2.27.0'
>>> pipster.install("requests", upgrade=True)
...
Successfully installed requests-2.28.2
WARNING: The following modules were already loaded. Restart python to see changes:
requests
Pipfiles
Pipfiles are ignored by pipster. If you use pipster from a directory that
contains a Pipfile (or whose parent directories up to a depth of 3 contain a
Pipfile), then pipster will issue a warning that Pipfiles are ignored.
Metadata
Release files for pipster 0.0.24
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pipster-0.0.24.tar.gz | 222.9 kB | Without provenance | Details for pipster-0.0.24.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pipster-0.0.24-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for pipster-0.0.24-py2.py3-none-any.whl |
Total release size: 237.2 kB
Release files / pipster-0.0.24.tar.gz
| Download URL | pipster-0.0.24.tar.gz |
|---|---|
| Size | 222.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
471ddc1ee389511b63045a136f0ed64a93bb8e308db95bad0755ab2222dea953
|
|
BLAKE2b-256 checksum How to use checksums |
c33e2f57517960bf45f5b60187856d100dac387193a9689905a71d68f2de88d2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.11.3
|
Release files / pipster-0.0.24-py2.py3-none-any.whl
| Download URL | pipster-0.0.24-py2.py3-none-any.whl |
|---|---|
| Size | 14.3 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
72a68e4331fb00a00ae65708483fd3996c7e93523c3cbcee7e3f6d69804bf1ec
|
|
BLAKE2b-256 checksum How to use checksums |
a847aa1baeed4ea403a1266a09106d31cd3eecb67bd15acc4cdc72eb03cd6452
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.11.3
|
Security for pipster 0.0.24
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.