我想知道我在Windows上的Python安装路径。例如:
C:\Python25
如何找到Python的安装位置?
我想知道我在Windows上的Python安装路径。例如:
C:\Python25
如何找到Python的安装位置?
当前回答
如果有人需要在c#中这样做,我使用以下代码:
static string GetPythonExecutablePath(int major = 3)
{
var software = "SOFTWARE";
var key = Registry.CurrentUser.OpenSubKey(software);
if (key == null)
key = Registry.LocalMachine.OpenSubKey(software);
if (key == null)
return null;
var pythonCoreKey = key.OpenSubKey(@"Python\PythonCore");
if (pythonCoreKey == null)
pythonCoreKey = key.OpenSubKey(@"Wow6432Node\Python\PythonCore");
if (pythonCoreKey == null)
return null;
var pythonVersionRegex = new Regex("^" + major + @"\.(\d+)-(\d+)$");
var targetVersion = pythonCoreKey.GetSubKeyNames().
Select(n => pythonVersionRegex.Match(n)).
Where(m => m.Success).
OrderByDescending(m => int.Parse(m.Groups[1].Value)).
ThenByDescending(m => int.Parse(m.Groups[2].Value)).
Select(m => m.Groups[0].Value).First();
var installPathKey = pythonCoreKey.OpenSubKey(targetVersion + @"\InstallPath");
if (installPathKey == null)
return null;
return (string)installPathKey.GetValue("ExecutablePath");
}
其他回答
两者都有可能
C: \ Python36 C:\Users\(您登录的用户)\AppData\Local\Programs\Python\Python36
C:\Users\Your_user_name\AppData\Local\Programs\Python
我目前安装的python版本是3.7.0
希望这能有所帮助!
选项1:检查系统环境变量>路径
选项2:C:\Users\Asus\AppData\Local\Programs\Python(默认路径)
其一般
'C:\Users\user-name\AppData\Local\Programs\Python\Python-version'
或 尝试使用(在CMD中)
python在哪里
你可以搜索“你的环境变量”。如果您已经在路径中添加了Python,它将在您的环境变量帐户中显示为“path”。
但你总是会发现 “C: \ \ % User_name % \ AppData \用户本地Python \程序\ \ Python_version”
“AppData”文件夹可能是隐藏的,使它从工具栏的视图部分可见。