python执行路径在哪?python lib库怎么找?site-packages在哪?怎么知道当前我正在使用哪个python?
只用一个命令就可以了:which
linyc ~ % which python3
/usr/bin/python3
linyc ~ % source ~/.bash_profile # 切换环境
(base) linyc ~ % which python3
/opt/miniconda3/bin/python3
当你找到了py3路径,相应的lib、site-packages也就能找到了
(base) linyc ~ % cd /opt/miniconda3/lib/python3.8/site-packages
(base) linyc site-packages % pwd
/opt/miniconda3/lib/python3.8/site-packages
不光是python,其他也可以用
(base) linyc ~ % which pip
/opt/miniconda3/bin/pip
(base) linyc ~ % which jupyter
/opt/miniconda3/bin/jupyter
有的同学很多时候要同时安装py2、py3.6、py3.8,也有的同学需要频繁切换环境,
所以很容易混乱,用which就可以解千愁了~
当然, 使用echo $PATH查看环境路径也是个好办法,具体就不展开了。