跨平台工具,将Python的用户bin目录添加到PATH,无需sudo/runas权限!
项目描述
当您通过 pip install --user ... 安装包时,任何可执行文件都会放置在专门为预期用户创建的特定目录中。不幸的是,这个位置可能不包括在您的用户PATH变量中。例如,如果您执行了 pip3 install --user hatch,然后尝试通过执行 hatch --help 来了解更多关于您的新工具的信息,它将无法找到。查看: https://github.com/pypa/pip/issues/3813
pybin通过提供一个小型CLI和相应的API来解决此问题,以定位Python的用户bin并可选择更新用户PATH。它支持所有主流操作系统,并且不需要提升权限!
请放心,这仅修改用户PATH;系统PATH永远不会被修改或查看!
安装
pybin 以通用 wheel 的形式在 PyPI 上分发,可在 Linux/macOS 和 Windows 上使用,并支持 Python 2.6-2.7/3.3+ 和 PyPy。
$ pip install pybin
不要使用 --user!
命令
只有 2 个!
pybin
$ 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
>>> from pybin import in_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
许可
pybin 的分发受以下两个条款的约束:
任选其一。
项目详情
下载文件
下载适合您平台的应用程序。如果您不确定要选择哪个,请了解更多关于 安装包 的信息。
源分发
pybin-0.3.4.tar.gz (9.0 kB 查看散列)
构建分发
pybin-0.3.4-py2.py3-none-any.whl (7.9 kB 查看散列)