WindowsでのPythonインストールパスを確認したい。例えば:
C:\Python25
Pythonがインストールされている場所を見つけるにはどうすればよいですか?
WindowsでのPythonインストールパスを確認したい。例えば:
C:\Python25
Pythonがインストールされている場所を見つけるにはどうすればよいですか?
回答:
Pythonインタープリターで、次のコマンドを入力します。
>>> import os
>>> import sys
>>> os.path.dirname(sys.executable)
'C:\\Python25'
              それは
C:\Users\YANG.LEI\AppData\Local\Programs\Python\Python36-32
                    C:\Users。
                    pythonインタープリターを開始せずに Windowsでインストールされているパスを知る必要がある場合は、Windowsレジストリーを調べてください。
インストールされている各Pythonバージョンには、次のいずれかにレジストリキーがあります。
HKLM\SOFTWARE\Python\PythonCore\versionnumber\InstallPathHKCU\SOFTWARE\Python\PythonCore\versionnumber\InstallPath64ビットWindowsでは、次のWow6432Nodeキーの下にあります。
HKLM\SOFTWARE\Wow6432Node\Python\PythonCore\versionnumber\InstallPathではsys、パッケージ、あなたのインストールに関する有用な情報をたくさん見つけることができます。
import sys
print sys.executable
print sys.exec_prefix
これがWindowsシステムに何を与えるかわかりませんが、私のMac executableではPythonバイナリとexec_prefixインストールルートを指しています。
sysモジュールを検査するためにこれを試すこともできます:
import sys
for k,v in sys.__dict__.items():
    if not callable(v):
        print "%20s: %s" % (k,repr(v))
              python -c "import sys; print sys.executable"
                    インストールが成功した後でパスが必要な場合は、最初にCMDを開いてpythonまたはpython -iと入力します
それはあなたのためにインタラクティブシェルを開き、次に入力します
インポートシステム
sys.executable
Enterキーを押すと、Pythonがインストールされているパスが表示されます...
簡単な方法は
1) open CMD
2) type >>where python
              Pythonがインストールされている場所を知るにはwhere python、cmd.exeで実行できます。
wherewhichです。
                    where pythoncmd.exeで動作を確認できます
                    誰かが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:\ Users \ USER \ AppData \ Local \ Programs \ Python \ Python36に移動していない場合は、windows + ^ Rでコンソールを開きます。ローカルファイルにインストールされている場合は、cmdと入力してpythonと入力します。バージョンが表示されます。そこから次のように入力しますimport os import sys os.path.dirname(sys.executable)
pyコマンドをインストールしている場合は、おそらくそれを行い、--list-pathsコマンドの引数を使用します。
py --list-paths
出力例:
Windowsのpy Launcherで検出されたインストール済みPython
-3.8-32 C:\ Users \ cscott \ AppData \ Local \ Programs \ Python \ Python38-32 \ python.exe *
-2.7-64 C:\ Python27 \ python.exe
*は、pyコマンドを使用して実行されるスクリプトの現在アクティブなバージョンを示します。
これは私のために働きました: C:\Users\Your_user_name\AppData\Local\Programs\Python
現在インストールされてpython versionいる3.7.0
お役に立てれば!
その一般的に
'C:\ Users \ user-name \ AppData \ Local \ Programs \ Python \ Python-version'
または(cmdで)使用してみてください
where python
あなたがまだ立ち往生している場合、またはこれを取得した場合
C:\\\Users\\\name of your\\\AppData\\\Local\\\Programs\\\Python\\\Python36
これを単に2 \を1つに置き換えます
C:\Users\akshay\AppData\Local\Programs\Python\Python36