【问题标题】:sudo pip install djangosudo pip install django
【发布时间】:2015-03-16 07:08:24
【问题描述】:

所以这是我第一次尝试安装 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

【问题讨论】:

    标签: python django pip


    【解决方案1】:

    这些消息只是告诉您,在发出 sudo 后,当前用户已更改为 root 并且 root 不是这些目录的所有者或父目录之一。

    sudo -H 将$HOME 环境变量设置为/root 并且可能会隐藏这些,但您这样做的方式非常好。

    我很确定这些消息没什么好担心的,但是看到人们正在阅读它们并确保它们总是很高兴。

    另外,要验证这一点,您可以尝试:

    $ sudo env | less
    

    和

    $ sudo -H env | less
    

    并注意 $HOME 和 $USER 变量

    【讨论】:

    • 非常感谢您的回答!我只是想确保它们不是会回来并在路上咬我的错误。
    • 这是否意味着我应该输入sudo install pip 而不是sudo -H install pip?
    • 感谢您的解释;这让我发疯了。然而,细节似乎是错误的,至少在 Ubuntu 16.04 上是这样。我看到除了 HOME 和 HOME = /root 之外的所有变量的值都相同,如果给出了 -H,如果没有给出我的主目录。我认为这与您所说的相反。
    猜你喜欢
    • 2015-06-13
    • 2015-06-01
    • 1970-01-01
    • 2016-08-04
    • 1970-01-01
    • 1970-01-01
    • 2014-09-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多