如何在全球而非本地安装pip软件包? [英] How do I install a pip package globally instead of locally?

查看:96
本文介绍了如何在全球而非本地安装pip软件包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用pip3安装flake8软件包,但似乎已拒绝安装,因为它已安装在一个本地位置.

I am trying to install flake8 package using pip3 and it seems that it refuses to install because is already installed in one local location.

如何强制它在全局(系统级别)安装?

How can I force it to install globally (system level)?

pip3 install flake8
Requirement already satisfied (use --upgrade to upgrade): flake8 in ./.local/lib/python3.4/site-packages

请注意,我更喜欢一种通用解决方案(应该在Debian,OS X甚至Windows上都可以使用),该解决方案可以在任何平台上使用,所以我不想自己指定目的地.

Please note that I would prefer a generic solution (that should work on Debian, OS X maybe even Windows), one that should be used on any platform so I don't want to specify the destination myself.

出于某种奇怪的原因,它的行为就像我已经指定了--user一样,在我的情况下我没有指定.

For some weird reason it behaves like I already specified --user which in my case I didn't.

我能够全局安装软件包的唯一方法是先将其删除,然后再重新安装.如果pip(8.1.1)本地存在,则似乎以某种方式拒绝全局安装软件包.

The only way I was able to install a package globally was to first remove it and install it again after this. Somehow it seems that pip (8.1.1) refuses to install a package globally if it exists locally.

免责声明:实验期间未使用或损害任何虚拟环境.

Disclaimer: No virtual environments were used or harmed during the experiments.

推荐答案

为什么不尝试将sudoH标志一起使用?这应该可以解决问题.

Why don't you try sudo with the H flag? This should do the trick.

sudo -H pip install flake8

常规sudo pip install flake8将尝试使用您自己的主目录. -H指示它使用系统的主目录.有关更多信息,请访问 https://stackoverflow.com/a/43623102/

A regular sudo pip install flake8 will try to use your own home directory. The -H instructs it to use the system's home directory. More info at https://stackoverflow.com/a/43623102/

这篇关于如何在全球而非本地安装pip软件包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆