How do I find the location of my Python site-packages directory?

前端 未结 21 3089
梦谈多话
梦谈多话 2020-11-22 03:06

How do I find the location of my site-packages directory?

21条回答
  •  深忆病人
    2020-11-22 03:20

    For Ubuntu,

    python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"
    

    ...is not correct.

    It will point you to /usr/lib/pythonX.X/dist-packages

    This folder only contains packages your operating system has automatically installed for programs to run.

    On ubuntu, the site-packages folder that contains packages installed via setup_tools\easy_install\pip will be in /usr/local/lib/pythonX.X/dist-packages

    The second folder is probably the more useful one if the use case is related to installation or reading source code.

    If you do not use Ubuntu, you are probably safe copy-pasting the first code box into the terminal.

提交回复
热议问题