怎么查看python的安装目录?
linux中一般安装后的默认路径如下
#!/usr/bin/env python 或者 #!/usr/locat/bin/python
如果没有找到,可以通过命令查询python路径
whereis python 或者 which python
相关推荐:《Python教程》
Windows OS
可以通过以下方式查询python路径或者第三方模块安装路径。
>>> import sys >>> sys.path ['', 'C:\\Python27\\Lib\\idlelib', 'C:\\Python27\\lib\\site-packages\\robotframework_selenium2library-1.5.0-py2.7.egg', 'C:\\Python27\\lib\\site-packages\\docutils-0.14-py2.7.egg', 'C:\\Python27\\lib\\site-packages\\decorator-4.2.1-py2.7.egg', 'C:\\Windows\\system32\\python27.zip', 'C:\\Python27\\DLLs', 'C:\\Python27\\lib', 'C:\\Python27\\lib\\plat-win', 'C:\\Python27\\lib\\lib-tk', 'C:\\Python27', 'C:\\Python27\\lib\\site-packages', 'C:\\Python27\\lib\\site-packages\\win32', 'C:\\Python27\\lib\\site-packages\\win32\\lib', 'C:\\Python27\\lib\\site-packages\\Pythonwin', 'C:\\Python27\\lib\\site-packages\\wx-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/lib/python3.5 /usr/lib/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/lib/python3.5 /usr/local/lib/python3.6 /usr/local/lib/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的安装目录的详细内容,更多请关注php中文网其它相关文章!