Why i can't do some things without sudo using Python and pip?

后端 未结 2 1501
滥情空心
滥情空心 2020-12-09 13:36

When I use pip it usually doesn\'t work without sudo. I often see people use pip without sudo, so what am I doing wrong?

I read that it is not recommended to install

2条回答
  •  醉梦人生
    2020-12-09 13:45

    The reason is that your regular user doesn't have the permissions needed to modify the system directories. Just like in this message:

    PermissionError: [Errno 13] Permission denied: '/usr/local/lib/python3.4/dist-packages/pip'
    

    Here is a brief rundown of what you need to know:

    Your system has python installed, in order to modify the system's python you have to use sudo or be the root user.

    You can install python libraries in your home directory without using sudo, but only you (not other users of the system) will be able to use it. Do this with pip install --user package-name like gongzhitaao mentioned.

    You can also create unique installations of python in a directory of your choosing, like The Laughing Man mentioned. This is called virtualenv, and I think this is the most-preferred way to work.

提交回复
热议问题