Python在我的机器上,我只是不知道在哪里,如果我在终端中输入Python,它会打开Python 2.6.4,这不是在它的默认目录中,肯定有一种方法可以从这里找到它的安装位置?
当前回答
Windows用户:
如果python命令不在您的$PATH环境中。
打开PowerShell并运行这些命令以找到该文件夹
cd \
ls *ython* -Recurse -Directory
这应该会告诉你python安装在哪里
其他回答
在类unix系统上,您应该能够键入哪个python,这将打印出python的路径。Windows命令提示符中的等效语句是where python, Windows Powershell中的Get-Command python。
另一种(跨平台)方法是将其输入IDLE或REPL(在终端中输入python):
import re
re.__file__
或者在你的终端上写一行:
python -c "import re; print(re.__file__)"
这将打印re模块的路径,从而显示python命令指向的位置。你可以放置你知道已经安装的任何其他模块,路径将指向该模块,也为你提供python的路径。
Sys有一些有用的东西:
$ python
Python 2.6.6 (r266:84297, Aug 24 2010, 18:13:38) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.executable
'c:\\Python26\\python.exe'
>>> sys.exec_prefix
'c:\\Python26'
>>>
>>> print '\n'.join(sys.path)
c:\Python26\lib\site-packages\setuptools-0.6c11-py2.6.egg
c:\Python26\lib\site-packages\nose-1.0.0-py2.6.egg
C:\Windows\system32\python26.zip
c:\Python26\DLLs
c:\Python26\lib
c:\Python26\lib\plat-win
c:\Python26\lib\lib-tk
c:\Python26
c:\Python26\lib\site-packages
c:\Python26\lib\site-packages\win32
c:\Python26\lib\site-packages\win32\lib
c:\Python26\lib\site-packages\Pythonwin
c:\Python26\lib\site-packages\wx-2.8-msw-unicode
在unix(包括mac os X)终端上可以这样做
which python
它会告诉你。
要找到Windows上所有的Python安装,在命令提示符处运行:
dir site.py /s
确保您在根驱动器中。你会看到类似这样的东西。
对于Windows CMD,执行:where python . exe
Windows PowerShell: Get-Command python
推荐文章
- 证书验证失败:无法获得本地颁发者证书
- 当使用pip3安装包时,“Python中的ssl模块不可用”
- 无法切换Python与pyenv
- Python if not == vs if !=
- 如何从scikit-learn决策树中提取决策规则?
- 为什么在Mac OS X v10.9 (Mavericks)的终端中apt-get功能不起作用?
- 将旋转的xtick标签与各自的xtick对齐
- 为什么元组可以包含可变项?
- 如何合并字典的字典?
- 如何创建类属性?
- 不区分大小写的“in”
- 在Python中获取迭代器中的元素个数
- 解析日期字符串并更改格式
- 使用try和。Python中的if
- 如何在Python中获得所有直接子目录