Skip to content

Instantly share code, notes, and snippets.

@ytez
Last active February 1, 2022 08:57
Show Gist options
  • Save ytez/0dd51c049c22f07be863260d0842026a to your computer and use it in GitHub Desktop.
Save ytez/0dd51c049c22f07be863260d0842026a to your computer and use it in GitHub Desktop.

Windows Python3 インストールメモ

手順

  1. executable installer 3.10.2 を実行
  2. 設定は下記の通り
    • Optional Features
      • Documentation
      • pip
      • tcl/tk and IDLE
      • Python test suite
      • py launcher
    • Advanced Options
      • Install for all users
      • Associate files with python (requires the py launcher)
      • Creates shortcuts for installed applications
      • Add Python to environment variables
      • Precompile standard library
      • Download debugging symbols
      • Download debug binaries
      • Customize install location C:\Data\Python\Python310\
    • Setup was successful
      • 実行: Disable path length limit Changes your machine configuration to allow programs, including Python, to bypass the 260 character "MAX_PATH" limitation.
  3. PATH の確認
    # PowerShell
    Get-WmiObject Win32_Environment | 
      ?{ $_.Name -eq 'Path' } |
      %{ $_.VariableValue = ($_.VariableValue -replace ";","`n"); $_ } | 
      Format-List Name,UserName,VariableValue
    Name          : Path
    UserName      : <SYSTEM>
    VariableValue : %SystemRoot%\system32
                    %SystemRoot%
                    %SystemRoot%\System32\Wbem
                    %SYSTEMROOT%\System32\WindowsPowerShell\v1.0\
                    %SYSTEMROOT%\System32\OpenSSH\
    
    Name          : Path
    UserName      : NT AUTHORITY\SYSTEM
    VariableValue : %USERPROFILE%\AppData\Local\Microsoft\WindowsApps
    
    
    Name          : Path
    UserName      : DESKTOP-WIN-02\admin
    VariableValue : C:\Data\Python\Python310\Scripts\
                    C:\Data\Python\Python310\
                    C:\Users\admin\AppData\Local\Programs\Python\Launcher\
                    %USERPROFILE%\AppData\Local\Microsoft\WindowsApps
    
  4. pip PATH 確認
    # PowerShell
    (Get-Command pip).Path
    C:\Data\Python\Python310\Scripts\pip.exe
    
  5. pip 更新
    pip install -U pip
  6. wheel インストール
    pip install wheel
  7. pip 以外のモジュールの一括更新
    # PowerShell
    pip install --upgrade (@(pip list --format freeze --exclude pip) | %{$_ -Replace '==.*$',''})

メモ

pip 以外のモジュールの一括更新

  • PowerShell から下記の様に実行する
  • pip list --outdated のほうが良いと思っていたが、依存関係解決のためには全モジュールを指定したほうが良さそう
pip install --upgrade (@(pip list --format freeze --exclude pip) | %{$_ -Replace '==.*$',''})

プロキシ環境下の場合

  • 環境変数 http_proxy https_proxyhttp://<proxy server>:<port> の形で設定する
  • pip だけのプロキシ設定の場合は %APPDATA%\pip\pip.ini に下記のように設定する
    [global]
    proxy = http://<proxy server>:<port>
@ytez
Copy link
Author

ytez commented Feb 1, 2022

モジュールの一括更新は --outdated をつけないほうが良さそう

PS> pip install --upgrade (@(pip list --outdated --format freeze --exclude pip) | %{$_ -Replace '==.*$',''})

Requirement already satisfied: mistune in c:\data\python\python310\lib\site-packages (0.8.4)
Collecting mistune
  Using cached mistune-2.0.2-py2.py3-none-any.whl (24 kB)
Installing collected packages: mistune
  Attempting uninstall: mistune
    Found existing installation: mistune 0.8.4
    Uninstalling mistune-0.8.4:
      Successfully uninstalled mistune-0.8.4
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
nbconvert 6.4.1 requires mistune<2,>=0.8.1, but you have mistune 2.0.2 which is incompatible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment