sudo pip install VS pip install --user

前端 未结 2 1685
傲寒
傲寒 2020-11-30 08:41

Can\'t remember where I read this, but either somewhere on here or in the comments of a tutorial I was following, a person said:

\'Never never ever use sudo pip ins

2条回答
  •  甜味超标
    2020-11-30 09:34

    $ sudo pip install 
    

    Installs the package globally in your python installation, i.e. for all users.

    $ pip install --user
    

    Installs to the local user directory, i.e. ~/.local/lib/python -- just you.

    Example:

    $ sudo pip install jupyter
    $ jupyter notebook
    

    Will run jupyter, open a web browser, allow you to work with notebooks.

    $ pip install --user jupyter
    $ jupyter notebook
    

    Will do nothing until your local directory has been added to your PATH.

    There was recently malicious code included in pypi. Never use sudo to install with pip. This is the same as running a virus as root. Either add your local folder to your PATH or use a virtualenv.

提交回复
热议问题