[英]Using pyenv, how can I pip install global CLIs and make them available even when in a virtualenv?
There are many pip-installed CLI's like ansible
and black
that I want to have access to always, no matter which python version or virtualenv I am using.有许多 pip 安装的 CLI,例如ansible
和black
,我希望始终可以访问它们,无论我使用的是哪个 python 版本或 virtualenv。 If I mark a certain python installation as global (a la pyenv global 3.10.0
), I can then use pip
to install these CLI's into that global python's site-packages, and pyenv makes them runnable while I'm using the global python. However, they become unavailable once I'm inside a virtualenv.如果我将某个 python 安装标记为全局(la pyenv global 3.10.0
),然后我可以使用pip
将这些 CLI 安装到该全局 python 的站点包中,并且 pyenv 使它们在我使用全局 python 时可运行。但是,一旦我进入 virtualenv,它们就变得不可用了。 This makes me no longer able to use tools for linting, deploying, and doing generic system-related tasks without installing these tools into the virtualenv, which I do not want to do.这使我无法在不将这些工具安装到 virtualenv 中的情况下使用工具进行 linting、部署和执行与系统相关的通用任务,这是我不想做的。
Is there a supported or common way of solving this problem so that I can install certain pip packages which include binaries, and have those binaries always accessible?是否有解决此问题的受支持或通用方法,以便我可以安装某些包含二进制文件的 pip 软件包,并始终可以访问这些二进制文件?
The Python Packaging Authority has a tool called PipX which is meant for exactly this purpose, check it out! Python Packaging Authority有一个名为PipX的工具,它正是用于此目的,请查看!
From the readme:从自述文件:
Overview: What is pipx?概述:什么是 pipx?
pipx is a tool to help you install and run end-user applications written in Python. It's roughly similar to macOS's brew, JavaScript's npx, and Linux's apt. pipx是Python编写的帮助安装运行终端用户应用程序的工具,大致类似于macOS的brew、JavaScript的npx、Linux的apt。
It's closely related to pip. In fact, it uses pip, but is focused on installing and managing Python packages that can be run from the command line directly as applications.它与 pip 密切相关。实际上,它使用 pip,但专注于安装和管理 Python 包,这些包可以直接从命令行作为应用程序运行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.