将“sudo pip”指Pythonpip

2024-03-28 08:19:45 发布

您现在位置:Python中文网/ 问答频道 /正文

我已经在我的ubuntu系统中安装了anaconda。在

如果我在终端中使用sudo pip,它似乎是指系统pip,而不是指水蟒pip。我运行sudo which pip来验证它。在

sudo which pip给了我/usr/local/bin/pip的输出, 并且which pip给了我/home/ubuntuUser/anaconda3/bin/pip的输出

如何更改配置,以便在使用sudo pip时,它引用我的Pythonpip


Tags: pip终端whichhomebinubuntuusrlocal
1条回答
网友
1楼 · 发布于 2024-03-28 08:19:45

键入pip时使用pip的哪个实例由$PATH环境变量的内容决定。作为安全措施,您的环境变量通常被sudo替换。您可以更改此值以保留现有的$PATH值,除非sudo被配置为不允许。从^{} manual

-E The -E (preserve environment) option indicates to the security policy that the user wishes to preserve their existing environment variables. The security policy may return an error if the -E option is specified and the user does not have permission to preserve the environment.

由于anaconda只在您的环境(而不是root环境)中可用,所以您需要将-E传递给sudo。在

相关问题 更多 >