Ubuntu 下查看Python的安装路径

作者: 云中布衣   分类:  操作系统    热度: (2247℃)   时间: 2016-12-16 12:35   标签: #ubuntu  #Python    

今天想找找PyQt的帮助文档来着,而PyQt作为Python的一个库,或许在Python的安装目录下吧,但是由于系统用pyenv管理了多个版本的python,我也记不住到底哪个版本安装到了哪个路径:

$ pyenv versions
* system (set by PYENV_VERSION environment variable)
  2.7.3
  3.4.0
  3.5.0
而我的PyQt是装在system版本中的,因此可以选择切换到system python 版本,然后用sys中的path直接打印出当前python版本的安装路径。
$ python
Python 2.7.12 (default, Nov 19 2016, 06:48:10) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print sys.path
['', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-i386-linux-gnu', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/local/lib/python2.7/dist-packages/pip-7.1.0-py2.7.egg', '/usr/local/lib/python2.7/dist-packages/Django-1.8.16-py2.7.egg', '/usr/local/lib/python2.7/dist-packages/easywebdav-1.2.0-py2.7.egg', '/usr/local/lib/python2.7/dist-packages/requests-2.12.3-py2.7.egg', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/PILcompat', '/usr/lib/python2.7/dist-packages/gtk-2.0', '/usr/lib/python2.7/dist-packages/wx-3.0-gtk2']

或者也可以用linux自带的命令which,来获取当前python的路径:

$ which python
/home/wayne/.pyenv/shims/python

$ which man  
/usr/bin/man 

如果不熟悉linux命令,我们可以通过man 函数来获取which命令的使用说明:

WHICH(1)                       General Commands Manual                       WHICH(1)

NAME
       which - locate a command

SYNOPSIS
       which [-a] filename ...

DESCRIPTION
       which returns the pathnames of the files (or links) which would be executed in
       the current environment, had  its  arguments  been  given  as  commands  in  a
       strictly  POSIX-conformant shell.  It does this by searching the PATH for exe‐
       cutable files matching the names of the arguments. It does not follow symbolic
       links.

<完>由云中布衣整理,转载请注明出处

56.8K

评论:

云中布衣 Say:
生命那么短,不如用Python!~~哈哈哈哈哈

2016-12-26 15:17


Say:
现在Python是有多火,随便一个博客打开都有Python。

2016-12-25 10:37


发表评论:

© 云中布衣 2015 | Driven by EMLOG  | SiteMap | RunTime: 7.44ms&RSS  |   | 回到顶部

文章数量【230】 评论数量【158】 稳定运行【1089天】

Visitor IP Address【54.224.111.99】