Fundamentals 6 min read

Using trypackage: A Command-Line Tool for Quick Python Package Trials

The article introduces trypackage, a lightweight Python CLI utility that automatically creates a temporary virtual environment, installs a specified package, launches an interactive shell with the package pre‑imported, and offers various options for Python version, shell type, persistence, and configuration.

IT Services Circle
IT Services Circle
IT Services Circle
Using trypackage: A Command-Line Tool for Quick Python Package Trials

When trying out new Python libraries, the large number of dependencies can quickly pollute the global environment, so developers often resort to creating a virtual environment for each trial. The author discovered trypackage , a tool designed to streamline this process.

Installation : Install the package with a single command: python3 -m pip install trypackage The tool itself only depends on the click library, making it lightweight. Because trypackage builds on virtualenv , you also need to install virtualenv and virtualenvwrapper : python3 -m pip install virtualenv virtualenvwrapper

Basic usage : Running try requests creates a temporary virtual environment, installs the requests package inside it, automatically starts a Python shell, and imports the package for immediate use. After exiting the shell, the temporary environment is removed.

Advanced options include specifying a Python interpreter with -p (e.g., try requests -p 3.8 or try requests -p /usr/bin/python3.7.1 ), choosing the interactive mode ( --shell python , --ipython , --shell ptpython , --shell bpython ), opening the package in an editor ( try requests --editor ), installing directly from a GitHub repository ( try user/repo ), reusing an existing virtual environment ( try requests --virtualenv ~/.try/sandbox ), persisting the environment with --keep , and setting a custom temporary directory with --tmpdir .

Configuration file : To avoid repeatedly typing options, create a config.ini in the application directory with defaults such as: [env] virtualenv=~/.try/sandbox python=3.8 shell=ipython keep=false always_use_editor=false tmpdir=~/.try The location of the app directory can be obtained via: >> import click >>> click.get_app_dir("try") '/Users/iswbm/Library/Application Support/try' With the configuration file in place, subsequent try commands will respect these settings.

Conclusion : trypackage provides a convenient, all‑in‑one solution for quickly testing Python packages without contaminating the global environment, demonstrating Python’s strength as a language for rapid, lazy‑friendly development.

CLIpythonvirtualenvpackage testingtrypackage
IT Services Circle
Written by

IT Services Circle

Delivering cutting-edge internet insights and practical learning resources. We're a passionate and principled IT media platform.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.