Why do I have to type `sudo` before every pip install?

前端 未结 1 465
粉色の甜心
粉色の甜心 2021-01-13 16:37

When installing packages, logged as my username, I always get permission denied unless I do:

sudo pip install.

How can I make it so this is not

相关标签:
1条回答
  • 2021-01-13 17:06

    Either, I would use virtualenv, as mentioned in comments to the question, or, leverage python's PYTHON_USERBASE to install modules only for your user:

    In your .bashrc add:

    export PYTHON_USERBASE=~/python_userbase
    

    then download your package, extract it, go inside the resulting dir, and run:

    python setup.py install --user
    

    or simply use:

    pip install <package> --user
    

    They'll all end up in ~/python_userbase/lib/pythonXXX/site-packages and not damage your system's site-packages

    Reference:

    pep-0370

    The last thing, this time, Unix related, you could modify /etc/sudoers and grant your user the rights to execute pip as root. But I would highly discourage you from doing this.

    0 讨论(0)
提交回复
热议问题