金子邦彦研究室インストールWindows の種々のソフトウェア(インストール)Python 最新版のインストール(ソースコードを使用)(Windows 上)

Python 最新版のインストール(ソースコードを使用)(Windows 上)

Windows で,Python をソースコードからビルドして,インストールする.

Python のインストール: 別ページ »で説明は,複数の方法がある.

関連する外部ページhttps://devguide.python.org/setup/#getting-the-source-code

前準備

Python のインストール: 別ページ »で説明(Windows 上)

Windows での Python のインストール: 別ページ »で説明: 別ページ »で説明(あとのトラブルが起きにくいような手順を定めている)

Python の公式ページ: https://www.python.org/

Git, cmake のインストール

Windows での Git, cmake のインストール手順: 別ページ »で説明している.

Git の URL: https://git-scm.com/

CMake の公式ダウンロードページ: https://cmake.org/download/

マイクロソフト Visual Studio Community ・C++ によるデスクトップ開発のインストール(Windows 上)

Windows でのマイクロソフト Visual Studio Community ・C++ によるデスクトップ開発のインストール: 別ページ »で説明している.

Python のビルドとインストール

  1. Visual Studio の x64 Native Tools コマンドプロンプトを開く.

    起動は,Windows のメニューで「Visual Studio 20..」の下の「x64 Native Tools コマンドプロンプト (x64 Native Tools Command Prompt)」を選ぶ.「x64」は,64ビット版の意味である.

    「x64 Native Tools コマンドプロンプト (x64 Native Tools Command Prompt)」がないとき:

    C++ ビルドツール (Build Tools) のインストールを行うことで, 「x64 Native Tools コマンドプロンプト (x64 Native Tools Command Prompt)」がインストールされる.その手順は,別ページ »で説明

  2. 作業ディレクトリとインストールディレクトリを削除する
    mkdir c:\tools
    rmdir /s /q cpython
    

    [image]
  3. Python のソースコードをダウンロード
    cd c:\
    git clone https://github.com/python/cpython.git
    

    [image]
  4. インストール手順の説明は PCbuild\readme.txt に記載されている.一読しておく
  5. プロジェクトの再ターゲットの操作

    c:\cpython\PCbuild\pythoncore.vcxproj を開く(右クリックメニューが便利).すると Visual Studio が起動する.

    ソリューションを右クリック.右クリックメニューで「ソリューションの再ターゲット」を選ぶ.

    [image]
  6. PCbuild\build.bat の実行

    ※ このとき作業ディレクトリ内に bzip, sqlite3, xz, zlib, libffi, openssl-bin, tcltk が自動でダウンロードが始まる

    cd c:\
    cd cpython
    .\PCbuild\build.bat
    

    [image]
  7. 終了の確認

    [image]
  8. 試しに起動してみる
    c:\cpython\PCbuild\amd64\python.exe
    

    [image]

    exit()」で終わる

  9. pip をインストール

    pip を使うときは,「c:\cpython\PCbuild\win32\python.exe -m pip」のように使う

    curl -O https://bootstrap.pypa.io/get-pip.py
    c:\cpython\PCbuild\amd64\python.exe get-pip.py
    

    [image]