What is python's site-packages directory?

后端 未结 3 1653
滥情空心
滥情空心 2020-12-04 05:42

The directory site-packages is mentioned in various Python related articles. What is it? How to use it?

3条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-04 06:02

    When you use --user option with pip, the package gets installed in user's folder instead of global folder and you won't need to run pip command with admin privileges.

    The location of user's packages folder can be found using:

    python -m site --user-site
    

    This will print something like:

    C:\Users\%USERNAME%\AppData\Roaming\Python\Python35\site-packages
    

    When you don't use --user option with pip, the package gets installed in global folder given by:

    python -c "import site; print(site.getsitepackages())"
    

    This will print something like:

    ['C:\\Program Files\\Anaconda3', 'C:\\Program Files\\Anaconda3\\lib\\site-packages'
    

    Note: Above printed values are for On Windows 10 with Anaconda 4.x installed with defaults.

提交回复
热议问题