简体   繁体   English

使用 pyenv,我 pip 如何安装全局 CLI 并使它们即使在 virtualenv 中也可用?

[英]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,例如ansibleblack ,我希望始终可以访问它们,无论我使用的是哪个 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.

相关问题 如何在 pyenv 中创建一个 post virtualenv 钩子来升级 pip 包 - How can I make a post virtualenv hook in pyenv to upgrade pip packages 即使安装了 pyenv-virtualenvwrapper,pyenv 也无法制作 virtualenv - pyenv can't make virtualenv even with pyenv-virtualenvwrapper installed 在`pyenv/pyenv-virtualenv`中,我可以创建一个引用`system`的virtualenv,即之前没有`pyenv install`吗? - in `pyenv/pyenv-virtualenv` can I create a virtualenv which refers to `system`, i.e. without a `pyenv install` before? 我如何在没有pip或virtualenv的情况下安装python软件包 - How can I install a python package without pip or virtualenv 当virtualenv处于活动状态时,将Pip安装强制进入全局环境 - Pip install forced into global environment, when virtualenv is active 如何安装virtualenv和/或pip - how to install virtualenv and/or pip 使用sudo安装pip软件包后,如何才能使其仅在本地可用? - How can I make pip packages only locally available after installing them with sudo? 为什么我不能“停用”pyenv / virtualenv? 如何“修复”安装 - Why can't I "deactivate" pyenv / virtualenv? How to "fix" installation 如何从我的 virtualenv 中获取 pip 以安装到 virtualenv - How do I get pip from my virtualenv to install to the virtualenv 如果我分别使用pip和pip3安装virtualenv,默认是什么? - What is the default if I install virtualenv using pip and pip3 respectively?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM