Dead simple CLI tool to try Python packages - It's never been easier! :package:

Overview

try - It's never been easier to try Python packages

Latest version released on PyPi Package license Package is available as wheel

try is an easy-to-use cli tool to try out Python packages.

Demo

Features

  • Install specific package version from PyPI
  • Install package from GitHub
  • Install in virtualenv using specific version of python
  • Specify alternative python package import name
  • Keep try environment after interactive session
  • Launch interactive python console with already imported package
  • Launch editor instead of interpreter
  • Launch arbitrary python shell instead of default python shell

Usage

try requests
try requests --ipython
try requests --shell ptipython
try requests -p 3.5
try requests -p /usr/bin/python3.4.1
try requests==2.8.1
try kennethreitz/requests --ipython
try click-didyoumean:click_didyoumean  # if python package name is different then pip package name
try requests --editor

Usage examples

Note: most of the following cli options can also be configured in the configuration file!

Try single python package:

try requests
try flask

Try multiple python packages in one session:

try requests flask

Try specific version of a package:

try requests==2.8.1  # tries version 2.8.1 of requests instead of latest

Try package from GitHub repository:

try <user>/<repo>  # syntax example
try kennethreitz/requests  # installs master branch of Kenneth's requests package from GitHub

Try package but import with different name than package name:

try <package_name>:<import_name>  # syntax example
try click-didyoumean:click_didyoumean  # install click-didyoumean but import click_didyoumean

Try package in already existing virtualenv:

try requests --virtualenv ~/.try/sandbox  # use virtualenv at ~/.try/sandbox

⇢ see virtualenv config value in env section in configuration file.

Try package with specific python version:

try requests --python 3.5  # use python3.5 in virtualenv
try requests -p 2.7  # use python2.7 in virtualenv
try requests -p ~/work/cpython/bin/python  # use python binary from specific location

⇢ see python config value in env section in configuration file.

Try package with specific shell/repl:

try requests --shell python  # use python repl (default value)
try requests --shell ipython  # use ipython
try requests --shell ptpython  # use ptpython
try requests --shell ptipython  # use ptipython
try requests --shell bpython  # use bpython
try requests --ipython  # use ipython - an alias for --shell ipython

⇢ see shell config value in env section in configuration file.

Try package writing a little script instead of opening shell:

try requests --editor  # opens $EDITOR or editor instead of shell

⇢ see always_use_editor config value in env section in configuration file.

Keep virtualenv files after try run:

try requests --keep

⇢ see keep config value in env section in configuration file.

Use a specific location for the virtualenv files:

try requests --tmpdir ~/.try

⇢ see tmpdir config value in env section in configuration file.

Configuration

try can be configured to your preferences - like always use ipython as a shell or always use python3.5. The configuration file is located in your users application configuration directory in a file called config.ini. This location is OS dependent and is specified here: http://click.pocoo.org/5/api/#click.get_app_dir

The following config.ini file shows all available configuration options:

[env]
virtualenv=~/.try/sandbox
python=3.5
shell=ipython
keep=false
always_use_editor=false
tmpdir=~/.try

Installation

Use pip to install try:

pip3 install trypackage

Help

try comes with an awesome CLI interface thanks to click.

Usage: try [OPTIONS] [PACKAGES]...

  Easily try out python packages.

Options:
  --virtualenv TEXT  Use already existing virtualenv.
  -p, --python TEXT  The python version to use.
  --ipython          Use ipython instead of python.
  --shell TEXT       Specify the python shell to use. (This will override
                     --ipython
  -k, --keep         Keep try environment files.
  -e, --editor       Try with editor instead of interpreter.
  --tmpdir TEXT      Specify location for temporary directory.
  --version          Show the version and exit.
  --help             Show this message and exit.

try was inspired by https://github.com/VictorBjelkholm/trymodule.

Comments
  • The executable python3.5 (from --python=python3.5) does not exist

    The executable python3.5 (from --python=python3.5) does not exist

    Hey,

    I'm trying to run this on Windows 10. After installing via pip I'm running into a couple separate issues

    1. try is masked by Windows PowerShell's try syntax
    2. Running as a python m (python -m try requests) results in the error: The executable python3.5 (from --python=python3.5) does not exist

    I'm using Python 3.5 installed to C:\Python35\python.exe

    Any help would be great!

    bug windows-support help-wanted 
    opened by tomsitter 16
  • Package don't run :| Error: from try.__main__ import main error syntax

    Package don't run :| Error: from try.__main__ import main error syntax

    I create a virtualenv in Python 3 and install trypackage, but when I try run the application, raise an error saying:

    (try)☁ try pip freeze click==6.4 trypackage==0.1.4

    (try)☁ try try requests File "/home/erichideki/projects/try/bin/try", line 7 from try.__main__ import main ^ SyntaxError: invalid syntax This problem is inside the try archive on /bin paste.

    Any thoughts?

    bug 
    opened by erichideki 9
  • bpython? Anyone?

    bpython? Anyone?

    Hi there,

    thanks for awesome package.

    Do you tink it's possible to add support for bpython? It's much better then ipython and I think many people would appreciate this.

    Thanks in advance.

    enhancement 
    opened by im-n1 7
  • Arbitrary Shells?

    Arbitrary Shells?

    Any reason not to allow arbitrary shells, instead of the ipython on/off switch? Personally, I'm using iptpython (a mix between ptpython and ipython). Would be lovely to be able to say:

    try requests --shell ipython
    try requests --shell iptpython
    

    or whatever shell someone is using.

    Awesome project btw. :)

    enhancement 
    opened by mknecht 4
  • tmpdir could be created in a noexec location

    tmpdir could be created in a noexec location

    If you have /tmp mounted with the safe option noexec, try will fail to activate virtualenv:

    $ LANG= try requests
    ==> Use python python2.7
    [*] Downloading packages: requests
    /bin/sh: env/bin/activate: No such file or directory
    [*] Command 'python -m pip install requests >> logs' exited with error code: 1. See /tmp/try-x05IFY/logs
    

    If I remount /tmp with exec right it works:

    $ LANG= try requests
    ==> Use python python2.7
    [*] Downloading packages: requests
    /tmp/try-cRSmIg/env/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
      InsecurePlatformWarning
    You are using pip version 7.1.2, however version 8.1.1 is available.
    You should consider upgrading via the 'pip install --upgrade pip' command.
    Python 2.7.5 (default, May 29 2013, 02:28:51) 
    [GCC 4.8.0] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> 
    

    The SSLContext and pip version warnings are not related to this issue.

    enhancement 
    opened by jrd 3
  • Use expected pip binary

    Use expected pip binary

    try seems to use the system-provided pip binary. (I got the out-of-date warning, which I don't get usually because my user-level pip is up to date.)

    This is not what I'd have expected: When I try python packages myself, I of course just type pip install whatever.

    opened by mknecht 2
  • Install error

    Install error

    The idea of try is awesome, thanks! Unfortunately I was trying to try try but I couldn't install it:

    $ python -V
    Python 3.5.1
    $ pip -V
    pip 8.1.0 from /usr/local/var/pyenv/versions/3.5.1/lib/python3.5/site-packages (python 3.5)
    $ pip install trypackage
    Collecting trypackage
      Using cached trypackage-0.1.1.tar.gz
        Complete output from command python setup.py egg_info:
        Traceback (most recent call last):
          File "<string>", line 1, in <module>
          File "/private/var/folders/lr/gd0yq9m90rv_gz682gqt7ylc0000gn/T/pip-build-ftxztokx/trypackage/setup.py", line 44, in <module>
            install_requires=list(x.name for x in parse_requirements("./requirements.txt")),
          File "/private/var/folders/lr/gd0yq9m90rv_gz682gqt7ylc0000gn/T/pip-build-ftxztokx/trypackage/setup.py", line 44, in <genexpr>
            install_requires=list(x.name for x in parse_requirements("./requirements.txt")),
          File "/usr/local/var/pyenv/versions/3.5.1/lib/python3.5/site-packages/pip/req/req_file.py", line 79, in parse_requirements
            "parse_requirements() missing 1 required keyword argument: "
        TypeError: parse_requirements() missing 1 required keyword argument: 'session'
    
        ----------------------------------------
    Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/lr/gd0yq9m90rv_gz682gqt7ylc0000gn/T/pip-build-ftxztokx/trypackage/
    ------------------------------------------------------------
    $
    

    Basically my setup is Mac OS X 11 (El Captain), using Python via pyenv.

    bug 
    opened by cuducos 2
  • Update package name in MANIFEST.in

    Update package name in MANIFEST.in

    from try to trypackage. It looks like the package name change was introduced in edf0430a13183dbe2774ed5214bf9e38214532d1, but MANIFEST.in didn't get updated.

    The incorrect package/folder name was causing the --editor flag to fail because installations didn't bundle trypackage/script.template

    Hope this helps, let me know if there's anything else you would like me to do!

    opened by brookskindle 1
  • no PS1 prefix with bash shell

    no PS1 prefix with bash shell

    I tried try out, and I am pleasantly surprised how easy it works. But I noticed that when I use bash as shell, there is no common venv prefix you usually get after running activate shell script. If I use as shell fish all is fine.

    opened by derVedro 0
  • Use plain python venv instead of virtualenv

    Use plain python venv instead of virtualenv

    The package was using virtualenv as an unlisted dependency. I'm switching here to using python -m venv instead, which appears to be part of the standard library. Without this, try is broken for me.

    opened by igordertigor 2
  • '.' is not recognized as an internal or external command, operable program or batch file.

    '.' is not recognized as an internal or external command, operable program or batch file.

    Hi, When I run try I get this error:

    λ try requests
    ==> Use python python3.6
    [*] Downloading packages: requests
    '.' is not recognized as an internal or external command,
    operable program or batch file.
    [*] Command 'python -m pip install  requests >> C:\Users\dkter\AppData\Local\Temp\try-on_npjrs\logs' exited with error code: 1. See C:\Users\dkter\AppData\Local\Temp\try-on_npjrs\logs
    

    The given log file contains the text:

    The path python3.6 (from --python=python3.6) does not exist
    

    I'm using Windows 10 and Python 3.6.

    windows-support help-wanted 
    opened by TheInitializer 4
Owner
Timo Furrer
Enthusiastic Hacker who loves Free Open Source Software, Linux, Python, Machine Learning and :penguin:. Commits are my own.
Timo Furrer
A simple CLI based any Download Tool, that find files and let you stream or download thorugh WebTorrent CLI or Aria or any command tool

Privateer A simple CLI based any Download Tool, that find files and let you stream or download thorugh WebTorrent CLI or Aria or any command tool How

Shreyash Chavan 2 Apr 4, 2022
Pyrdle - Play Wordle in the CLI. Write an algorithm to play Wordle for you. Ruin all of the fun you've been having

Pyrdle - Play Wordle in the CLI. Write an algorithm to play Wordle for you. Ruin all of the fun you've been having

Charles Tapley Hoyt 11 Feb 11, 2022
A simple script to make the operation of AltServer-Linux more easier with cli

A simple script to make the operation of AltServer-Linux more easier with cli

powen 23 Dec 13, 2022
You'll never want to use cd again.

Jmp Description Have you ever used the cd command? You'll never touch that outdated thing again when you try jmp. Navigate your filesystem with unprec

Grant Holmes 21 Nov 3, 2022
Sink is a CLI tool that allows users to synchronize their local folders to their Google Drives. It is similar to the Git CLI and allows fast and reliable syncs with the drive.

Sink is a CLI synchronisation tool that enables a user to synchronise local system files and folders with their Google Drives. It follows a git C

Yash Thakre 16 May 29, 2022
[WIP]An ani-cli like cli tool for movies and webseries

mov-cli A cli to browse and watch movies. Installation This project is a work in progress. However, you can try it out python git clone https://github

null 166 Dec 30, 2022
Python package with library and CLI tool for analyzing SeaFlow data

Seaflowpy A Python package for SeaFlow flow cytometer data. Table of Contents Install Read EVT/OPP/VCT Files Command-line Interface Configuration Inte

SeaFlow@UW 3 Nov 3, 2021
Python-Stock-Info-CLI: Get stock info through CLI by passing stock ticker.

Python-Stock-Info-CLI Get stock info through CLI by passing stock ticker. Installation Use the following command to install the required modules at on

Ayush Soni 1 Nov 5, 2021
Yts-cli-streamer - A CLI movie streaming client which works on yts.mx API written in python

YTSP It is a CLI movie streaming client which works on yts.mx API written in pyt

null 1 Feb 5, 2022
flora-dev-cli (fd-cli) is command line interface software to interact with flora blockchain.

Install git clone https://github.com/Flora-Network/fd-cli.git cd fd-cli python3 -m venv venv source venv/bin/activate pip install -e . --extra-index-u

null 14 Sep 11, 2022
AWS Interactive CLI - Allows you to execute a complex AWS commands by chaining one or more other AWS CLI dependency

AWS Interactive CLI - Allows you to execute a complex AWS commands by chaining one or more other AWS CLI dependency

Rafael Torres 2 Dec 10, 2021
Simple script to download OTA packages from Realme's endpoint.

Realme OTA Downloader CLI tool (based on this C# program) to create requests to the Realme's endpoint. Requirements Python 3.9. pycryptodome. Installa

Roger Ortiz 64 Dec 28, 2022
A simple Python CLI tool that draws routes/paths on a given map.

Map Router A simple Python CLI tool that draws routes/paths on a given map. Index Installation Usage Docs Why? License Support Installation Coming soo

Pedro Morim 1 Nov 7, 2021
A Simple Python CLI Lockpicking Tool

Cryptex a simple CLI lockpicking tool What can it do: Encode / Decode Hex Encode / Decode Base64 Break Randomly :D Requirements: Python3 Linux as your

Alex Kollar 23 Jul 4, 2022
Simple CLI tool to track your cryptocurrency portfolio in real time.

Simple tool to track your crypto portfolio in realtime. It can be used to track any coin on the BNB network, even obscure coins that are not listed or trackable by major portfolio tracking applications.

Trevor White 69 Oct 24, 2022
A simple cli tool to commit Conventional Commits

convmoji A simple cli tool to commit Conventional Commits. Requirements Install pip install convmoji convmoji --help Examples A conventianal commit co

null 3 Jul 4, 2022
A simple CLI tool for tracking Pikud Ha'oref alarms.

Pikud Ha'oref Alarm Tracking A simple CLI tool for tracking Pikud Ha'oref alarms. Polls the unofficial API endpoint every second for incoming alarms.

Yuval Adam 24 Oct 10, 2022
Hack-All is a simple CLI tool that helps ethical-hackers to make a reverse connection without knowing the target device in use is it computer or phone

Hack-All is a simple CLI tool that helps ethical-hackers to make a reverse connection without knowing the target device in use is it computer

LightYagami17 5 Nov 22, 2022