一款用于尝试Python包的出色命令行工具
项目描述
try 是一个易于使用的命令行工具,用于尝试Python包。
功能
从PyPI安装特定版本的包
从GitHub安装包
使用特定版本的Python在虚拟环境中安装
指定替代的Python包导入名称
在交互式会话后保持try环境
启动带有已导入包的交互式Python控制台
启动编辑器而不是解释器
启动任意Python shell而不是默认的Python shell
用法
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
用法示例
注意:以下大多数CLI选项也可以在 配置文件 中配置!
尝试单个Python包
try requests
try flask
在一次会话中尝试多个Python包
try requests flask
尝试特定版本的包
try requests==2.8.1 # tries version 2.8.1 of requests instead of latest
尝试GitHub仓库中的包
try <user>/<repo> # syntax example
try kennethreitz/requests # installs master branch of Kenneth's requests package from GitHub
尝试包,但导入的名称与包名称不同
try <package_name>:<import_name> # syntax example
try click-didyoumean:click_didyoumean # install click-didyoumean but import click_didyoumean
在已存在的虚拟环境中尝试包
try requests --virtualenv ~/.try/sandbox # use virtualenv at ~/.try/sandbox
⇢ 请参阅配置文件中env部分中的虚拟环境配置值。 配置 文件。
尝试使用特定Python版本的包
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
⇢ 请参阅配置文件中env部分中的Python配置值。
尝试使用特定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
⇢ 请参阅配置文件中env部分中的shell配置值。
尝试通过编写少量脚本而不是打开shell来尝试包
try requests --editor # opens $EDITOR or editor instead of shell
⇢ 请查看配置文件中的 always_use_editor 配置值,在环境部分 配置 文件。
尝试运行后保留虚拟环境文件
try requests --keep
⇢ 请查看配置文件中的 keep 配置值,在环境部分 配置 文件。
为虚拟环境文件使用特定位置
try requests --tmpdir ~/.try
⇢ 请查看配置文件中的 tmpdir 配置值,在环境部分 配置 文件。
配置
try 可以根据您的喜好进行配置 - 例如,始终使用 ipython 作为 shell 或始终使用 python3.5。配置文件位于您的用户应用程序配置目录中,名为 config.ini 的文件中。此位置取决于操作系统,此处指定为: http://click.pocoo.org/5/api/#click.get_app_dir
以下 config.ini 文件显示了所有可用的配置选项
[env]
virtualenv=~/.try/sandbox
python=3.5
shell=ipython
keep=false
always_use_editor=false
tmpdir=~/.try
安装
使用 pip 安装 try
pip3 install trypackage
帮助
try 拥有出色的 CLI 界面,归功于 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 受 https://github.com/VictorBjelkholm/trymodule 的启发。
项目详情
trypackage-0.3.0.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 2934ef013348f2aa6a3782ce975a8955905521d35ebbb0b8642a0b2d9af3472d |
|
MD5 | dae3f09aeb75450fb1286674cb77a185 |
|
BLAKE2b-256 | 6bd7b3225f443c9403f699b56aa3a2af5fbf9e3bcb5af4565ab726c94c26d33d |