Is it acceptable and safe to run pip install under sudo?

后端 未结 6 972
时光说笑
时光说笑 2020-11-22 14:29

I\'ve started to use my Mac to install Python packages in the same way I do with my Windows PC at work; however on my Mac I\'ve come across frequent permission denied

6条回答
  •  眼角桃花
    2020-11-22 14:47

    Use a virtual environment:

    $ virtualenv myenv
    .. some output ..
    $ source myenv/bin/activate
    (myenv) $ pip install what-i-want
    

    You only use sudo or elevated permissions when you want to install stuff for the global, system-wide Python installation.

    It is best to use a virtual environment which isolates packages for you. That way you can play around without polluting the global python install.

    As a bonus, virtualenv does not need elevated permissions.

提交回复
热议问题