zoukankan      html  css  js  c++  java
  • 如何查看Python3安装及第三方库路径

    有时候,我们想要查找Python安装路径及第三方库的存放路径,但可能忘记了当初安装时的具体路径,这个时候我们就可以通过命令快速找到这些路径。

    查找Python安装路径

    • Windows下查找命令:where python3
    D:>where python3
    D:Pythoninstallationpython3.exe
    C:UserswintestAppDataLocalMicrosoftWindowsAppspython3.exe
    
    • Linux / Mac 下查找命令:which python3
    [root@wintest ~]# which python3
    /usr/bin/python3
    

    在 Linux & Mac 下,我们查到的很可能是软链接形式,它并不是安装的实际路径,但我们可以通过 ls -l 命令找到其指向的文件路径。

    [root@wintest ~]# ls -l /usr/bin/python3
    lrwxrwxrwx 1 root root 28 Sep  7  2019 /usr/bin/python3 -> /root/python36/bin/python3.6
    

    查找Python第三方库路径

    如果需要查找Python第三方库 site-packages 的存放路径,我们可以直接进入Python交互模式,借助 sys.path 来快速找到。

    [root@wintest ~]# python3
    Python 3.6.8 (default, Sep  7 2019, 18:50:26) 
    [GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import sys
    >>> sys.path
    ['', '/root/python36/lib/python36.zip', '/root/python36/lib/python3.6', '/root/python36/lib/python3.6/lib-dynload', '/root/python36/lib/python3.6/site-packages']
    

    不管是 Windows / Linux / Mac ,我们都可以通过以上方式来找到Python第三方库路径。

    作者:wintest
    本文版权归作者和博客园共有,欢迎转载,但必须在文章页面明显位置给出原文链接,并保留此段声明,否则保留追究法律责任的权利。
  • 相关阅读:
    Linux install
    plafrom library
    lua 线程
    plafrom SDK
    CSS中的focus-within伪类选择器
    网站打开速度优化_如何提高网页访问速度技巧方法总结
    网页预加载_骨架屏Skeleton Screen的实现
    SASS简介及使用方法
    什么是BFC布局——浅析BFC布局的概念以及作用
    JAVA面试题(九):JVM
  • 原文地址:https://www.cnblogs.com/wintest/p/14906342.html
Copyright © 2011-2022 走看看