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

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

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

21条回答
  •  醉酒成梦
    2020-11-22 03:39

    Let's say you have installed the package 'django'. import it and type in dir(django). It will show you, all the functions and attributes with that module. Type in the python interpreter -

    >>> import django
    >>> dir(django)
    ['VERSION', '__builtins__', '__doc__', '__file__', '__name__', '__package__', '__path__', 'get_version']
    >>> print django.__path__
    ['/Library/Python/2.6/site-packages/django']
    

    You can do the same thing if you have installed mercurial.

    This is for Snow Leopard. But I think it should work in general as well.

提交回复
热议问题