How to check the python installation directory

藏色散人
Release: 2019-08-02 10:31:19
Original
7445 people have browsed it

How to check the python installation directory

怎么查看python的安装目录?

linux中一般安装后的默认路径如下

#!/usr/bin/env python 
或者
#!/usr/locat/bin/python
Copy after login

如果没有找到,可以通过命令查询python路径

whereis python
或者
which python
Copy after login

相关推荐:《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']
Copy after login

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
Copy after login

使用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)
Copy after login

The above is the detailed content of How to check the python installation directory. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!