美文网首页
ubuntu下python包安装位置

ubuntu下python包安装位置

作者: 明月清风_5c62 | 来源:发表于2020-02-17 15:53 被阅读0次

    方法1

    查看当前版本python执行命令路径:

    tu@tu-Aspire-A615-51G:~$ which python
    /home/tu/local/anaconda3/bin/python
    

    相应的包安装在lib下,所以包路径即在/home/tu/local/anaconda3/lib/pythonX.X/下。

    方法2

    查看已安装的包:

    tu@tu-Aspire-A615-51G:~$ pip list
    Package                            Version    
    ---------------------------------- -----------
    absl-py                            0.6.1      
    alabaster                          0.7.10     
    anaconda-client                    1.6.9      
    anaconda-navigator                 1.7.0      
    ...
    

    任选安装的一个包,查看包的安装路径:

    tu@tu-Aspire-A615-51G:~$ python -c "import alabaster;print(alabaster)"
    <module 'alabaster' from '/home/tu/local/anaconda3/lib/python3.6/site-packages/alabaster/__init__.py'>
    

    或者

    tu@tu-Aspire-A615-51G:~$ pip show alabaster
    Name: alabaster
    Version: 0.7.10
    Summary: A configurable sidebar-enabled Sphinx theme
    Home-page: https://alabaster.readthedocs.io
    Author: Jeff Forcier
    Author-email: jeff@bitprophet.org
    License: UNKNOWN
    Location: /home/tu/local/anaconda3/lib/python3.6/site-packages
    Requires: 
    Required-by: Sphinx
    

    或者直接查找sys包,原理类似:

    >>> import sys
    >>> sys.path
    ['', '/home/tu/local/anaconda3/lib/python36.zip', '/home/tu/local/anaconda3/lib/python3.6', '/home/tu/local/anaconda3/lib/python3.6/lib-dynload', '/home/tu/local/anaconda3/lib/python3.6/site-packages', '/home/tu/local/anaconda3/lib/python3.6/site-packages/autopep8-1.3.5-py3.6.egg', '/home/tu/local/anaconda3/lib/python3.6/site-packages/torchvision-0.2.1-py3.6.egg']
    

    相关文章

      网友评论

          本文标题:ubuntu下python包安装位置

          本文链接:https://www.haomeiwen.com/subject/pdwbfhtx.html