跨平台工具将python的用户bin放在path中,不需要sudo/runas!
pybin的Python项目详细描述
通过pip install --user ...安装包时,任何可执行文件都会 放在一个特别的目录中,专门为预定的用户。不幸的是, 此位置很可能不包含在用户的路径变量中。所以为了 例如,如果您执行了pip3 install --user hatch,然后尝试了解更多 关于您的新工具通过hatch --help,它将无法定位。 见:https://github.com/pypa/pip/issues/3813
pybin通过为 找到python的用户bin并有选择地更新用户路径。它支持 所有主要操作系统,不需要提升权限!
Fear not, this only modifies the user PATH; the system PATH is never touched nor even looked at!
Table of Contents
安装
pybin作为一个通用的 wheel和在linux/macos和windows上可用,并支持 python 2.6-2.7/3.3+和pypy。
$ pip install pybin
不要使用--user!
命令
只有2个!
皮宾
$ pybin -h Usage: pybin [OPTIONS] COMMAND [ARGS]... Shows the location of the bin directory and whether or not it is in the user PATH. Options: -p, --pypath TEXT An absolute path to a Python executable. --version Show the version and exit. -h, --help Show this message and exit. Commands: put Updates the user PATH
Pybin Put
$ pybin put -h Usage: pybin put [OPTIONS] Updates the user PATH. The shell must be restarted for the update to take effect. Options: -p, --pypath TEXT An absolute path to a Python executable. -f, --force Update PATH even if it appears to be correct. -h, --help Show this message and exit.
API
>>>frompybinimportin_path,locate,put_in_path>>>in_path()False>>>locate()'C:\\Users\\Ofek\\AppData\\Roaming\\Python\\Python36\\Scripts'>>>success=put_in_path()
手动修改
使用pybin显示的位置与这个非常全面的文档相一致 Java提供了:https://www.java.com/en/download/help/path.xml