Find where python is installed (if it isn't default dir)

后端 未结 11 1443
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-04 06:09

Python is on my machine, I just don\'t know where, if I type python in terminal it will open Python 2.6.4, this isn\'t in it\'s default directory, there surely is a way of f

11条回答
  •  忘掉有多难
    2020-12-04 07:06

    sys has some useful stuff:

    $ python
    Python 2.6.6 (r266:84297, Aug 24 2010, 18:13:38) [MSC v.1500 64 bit (AMD64)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import sys
    >>> sys.executable
    'c:\\Python26\\python.exe'
    >>> sys.exec_prefix
    'c:\\Python26'
    >>>
    >>> print '\n'.join(sys.path)
    
    c:\Python26\lib\site-packages\setuptools-0.6c11-py2.6.egg
    c:\Python26\lib\site-packages\nose-1.0.0-py2.6.egg
    C:\Windows\system32\python26.zip
    c:\Python26\DLLs
    c:\Python26\lib
    c:\Python26\lib\plat-win
    c:\Python26\lib\lib-tk
    c:\Python26
    c:\Python26\lib\site-packages
    c:\Python26\lib\site-packages\win32
    c:\Python26\lib\site-packages\win32\lib
    c:\Python26\lib\site-packages\Pythonwin
    c:\Python26\lib\site-packages\wx-2.8-msw-unicode
    

提交回复
热议问题