sudo pip install django

16

这是我第一次尝试安装Django,当我运行它时,成功安装了Django-1.7.3,但我收到了以下警告。我找不到关于它们的任何信息,所以希望有人能澄清它们的含义,如果需要修复它们,我该如何去做?

谢谢!以下是我的终端输出

macbook:~ Asif$ sudo pip install Django
Password:
The directory '/Users/Asif/Library/Logs/pip' or its parent directory is not owned by the current user and the debug log has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want the -H flag.
The directory '/Users/Asif/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want the -H flag.
The directory '/Users/Asif/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want the -H flag.
Collecting Django
  Downloading Django-1.7.3-py2.py3-none-any.whl (7.4MB)
    100% |################################| 7.4MB 2.3MB/s 
Installing collected packages: Django

Successfully installed Django-1.7.3
1个回答

19

这些消息告诉您,在使用sudo命令之后,当前用户已更改为root,而root不是那些目录或其中一个父目录的所有者。

sudo -H会将$HOME环境变量设置为/root,可能会隐藏这些消息,但您现在这样做也完全没有问题。

我相当确定这些消息并无需担心,但总是好的看到人们正在阅读它们并确保安全。

另外,要验证此内容,您可以尝试:

$ sudo env | less

$ sudo -H env | less

并且注意$HOME和$USER这两个变量


非常感谢您的回答!我只是想确保这些不是未来会导致麻烦的错误。 - Asif
1
这是否意味着我应该键入 sudo install pip 而不是 sudo -H install pip - Zelong
谢谢您的解释,这让我感到非常困惑。然而,在Ubuntu 16.04上,细节似乎是错误的。我看到所有变量的值都相同,除了HOME之外,如果给出-H,则HOME = /root,否则为我的主目录。我认为这与您所说的相反。 - saulspatz

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接