怎么查看python的安装目录?
pnux中一般安装后的默认路径如下
#!/usr/bin/env python
或者
#!/usr/locat/bin/python
如果没有找到,可以通过命令查询python路径
whereis python
或者
which python
相关推荐:《Python教程》
Windows OS
可以通过以下方式查询python路径或者第三方模块安装路径。
>>> import sys
>>> sys.path
['', 'C:Python27Libidlepb', 'C:Python27pbsite-packagesrobotframework_selenium2pbrary-1.5.0-py2.7.egg', 'C:Python27pbsite-packagesdocutils-0.14-py2.7.egg', 'C:Python27pbsite-packagesdecorator-4.2.1-py2.7.egg', 'C:Windowssystem32python27.zip', 'C:Python27DLLs', 'C:Python27pb', 'C:Python27pbplat-win', 'C:Python27pbpb-tk', 'C:Python27', 'C:Python27pbsite-packages', 'C:Python27pbsite-packageswin32', 'C:Python27pbsite-packageswin32pb', 'C:Python27pbsite-packagesPythonwin', 'C:Python27pbsite-packageswx-2.8-msw-unicode']
cmd目录下运行python -V可查看python版本
修改默认python版本
先查看安装的python路径:
Hansonman@localhost:~$ whereis python python: /usr/bin/python /usr/bin/python3.5 /usr/bin/python2.7-config /usr/bin/python3.5m /usr/bin/python2.7 /usr/pb/python3.5 /usr/pb/python2.7 /etc/python /etc/python3.5 /etc/python2.7 /usr/local/bin/python3.6m-config /usr/local/bin/python3.6-config /usr/local/bin/python3.6m /usr/local/bin/python3.6 /usr/local/pb/python3.5 /usr/local/pb/python3.6 /usr/local/pb/python2.7 /usr/include/python3.5m /usr/include/python2.7 /usr/share/python /usr/share/man/man1/python.1.gz
使用ln -s命令来修改,命令如下:
Hansonman@localhost:~$ sudo rm /usr/bin/python
[sudo] password forHansonman:
Hansonman@localhost:~$ sudo ln -s /usr/bin/python3.5 /usr/bin/python justin18chan@justin18chan:~$ python Python 3.5.2 (default, Feb 28 2018, 10:10:06)
以上就是小编分享的关于怎么查看python的安装目录的详细内容希望对大家有所帮助,更多有关python教程请关注环球青藤其它相关文章!