sudo pip install django

2020-06-02 08:57发布

问题:

So this is my first attempt at trying to install Django, and when I ran it, it successfully installed Django-1.7.3 but I received these warnings below. I wasn't able to find any information about it online so I was hoping someone could clarify what they mean, if I need to fix them, and how I could go about doing that?

Thanks! below is the output from my terminal

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:

These messages are just telling you that after issuing sudo the current user has changed to root and root isn't the owner of those directories or one of the parent directories.

sudo -H sets the $HOME environment variable to /root and would probably hide these but the way you did it is perfectly fine.

I'm pretty sure these messages are nothing to be concerned about, but its always good to see that people are reading them and making sure.

Also, to verify this, you can try:

$ sudo env | less

and

$ sudo -H env | less

and pay attention to the $HOME and $USER variables