python:pipx

pipx - 分離環境での Python アプリケーションのインストールと実行

pipx logo
本家: pipx 翻訳
ソースコード: pypa/pipx: Install and Run Python Applications in Isolated Environments 翻訳

pipx は、Python で書かれたエンドユーザー アプリケーションのインストールと実行を支援するツールです。これは、macOS のbrew、JavaScript のnpx、および Linux の apt とほぼ同様である。
分離を追加しながらシェル内でアプリを利用できるようにするため、アプリケーションのインストール専用に作成されている。
pipx は、各アプリケーションとその関連パッケージに対して分離された環境を作成する。
Overview: What is pipx? - pipx.pypa.io より

公式: Install pipx - Installation - pipx 翻訳

Fedora

$ python3 -m pip install --user pipx

Collecting pipx
  Downloading pipx-1.2.0-py3-none-any.whl (57 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 57.8/57.8 kB 318.0 kB/s eta 0:00:00
Requirement already satisfied: argcomplete>=1.9.4 in /usr/lib/python3.11/site-packages (from pipx) (2.0.0)
Requirement already satisfied: packaging>=20.0 in /usr/lib/python3.11/site-packages (from pipx) (23.0)
Collecting userpath>=1.6.0
  Downloading userpath-1.9.0-py3-none-any.whl (9.0 kB)
Requirement already satisfied: click in /usr/lib/python3.11/site-packages (from userpath>=1.6.0->pipx) (8.1.3)
Installing collected packages: userpath, pipx
  WARNING: The script userpath is installed in '/home/tomoyan/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The script pipx is installed in '/home/tomoyan/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed pipx-1.2.0 userpath-1.9.0

Windows

$ python3 -m pip install --user pipx

Collecting pipx
  Downloading pipx-1.2.0-py3-none-any.whl (57 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 57.8/57.8 kB 610.0 kB/s eta 0:00:00
Collecting argcomplete>=1.9.4 (from pipx)
  Obtaining dependency information for argcomplete>=1.9.4 from https://files.pythonhosted.org/packages/4f/ef/8b604222ba5e5190e25851aa3a5b754f2002361dc62a258a8e9f13e866f4/argcomplete-3.1.1-py3-none-any.whl.metadata
  Downloading argcomplete-3.1.1-py3-none-any.whl.metadata (16 kB)
Collecting colorama>=0.4.4 (from pipx)
  Downloading colorama-0.4.6-py2.py3-none-any.whl (25 kB)
Collecting packaging>=20.0 (from pipx)
  Downloading packaging-23.1-py3-none-any.whl (48 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 48.9/48.9 kB 822.7 kB/s eta 0:00:00
Collecting userpath>=1.6.0 (from pipx)
  Obtaining dependency information for userpath>=1.6.0 from https://files.pythonhosted.org/packages/54/e4/5a33b7d5d2a7387ad7d5cf11cab2b832fd36ace778597e365595c5a12041/userpath-1.9.0-py3-none-any.whl.metadata
  Downloading userpath-1.9.0-py3-none-any.whl.metadata (3.0 kB)
Collecting click (from userpath>=1.6.0->pipx)
  Obtaining dependency information for click from https://files.pythonhosted.org/packages/1a/70/e63223f8116931d365993d4a6b7ef653a4d920b41d03de7c59499962821f/click-8.1.6-py3-none-any.whl.metadata
  Downloading click-8.1.6-py3-none-any.whl.metadata (3.0 kB)
Downloading argcomplete-3.1.1-py3-none-any.whl (41 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 41.5/41.5 kB 504.0 kB/s eta 0:00:00
Downloading userpath-1.9.0-py3-none-any.whl (9.0 kB)
Downloading click-8.1.6-py3-none-any.whl (97 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 97.9/97.9 kB 942.7 kB/s eta 0:00:00
Installing collected packages: packaging, colorama, argcomplete, click, userpath, pipx
Successfully installed argcomplete-3.1.1 click-8.1.6 colorama-0.4.6 packaging-23.1 pipx-1.2.0 userpath-1.9.0

pipx ensurepath を実行すると $PATH:~/.local/bin が設定されて /usr/bin が優先になるので注意が必要である🤔

$ grep -d skip -A 1 "Created by" ~/.* --exclude='*history'

/home/tomoyan/.commonshrc:# Created by `pipx` on 2024-02-02 08:14:31
/home/tomoyan/.commonshrc-export PATH="$PATH:/home/tomoyan/.local/bin"
--
/home/tomoyan/.zprofile:# Created by `pipx` on 2024-02-02 08:14:31
/home/tomoyan/.zprofile-export PATH="$PATH:/home/tomoyan/.local/bin"

pipx 1.4.3 では userpath.append で pipx の location_str (~/.local/bin) を追加する実装

$ curl -L https://raw.githubusercontent.com/pypa/pipx/1.4.3/src/pipx/commands/ensure_path.py 2>/dev/null | bat -n -l py -r 54:64

  54 def ensure_path(location: Path, *, force: bool) -> Tuple[bool, bool]:
  55     """Ensure location is in user's PATH or add it to PATH.
  56     Returns True if location was added to PATH
  57     """
  58     location_str = str(location)
  59     path_added = False
  60     need_shell_restart = userpath.need_shell_restart(location_str)
  61     in_current_path = userpath.in_current_path(location_str)
  62 
  63     if force or (not in_current_path and not need_shell_restart):
  64         path_added = userpath.append(location_str, "pipx")

$ which pip && python -s -m pip -V && echo '---- ✂  ----' && python -m pip -V && echo '---- ✂  ----' && echo $PATH | grep : && echo '---- ✂  ----' && python -m site

/usr/bin/pip
pip 23.2.1 from /usr/lib/python3.12/site-packages/pip (python 3.12)
---- ✂  ----
pip 23.2.1 from /usr/lib/python3.12/site-packages/pip (python 3.12)
---- ✂  ----
/home/tomoyan/miniforge3/condabin:/home/tomoyan/.deno/bin:/home/tomoyan/.anyenv/envs/nodenv/shims:/home/tomoyan/.anyenv/envs/nodenv/bin:/home/tomoyan/.anyenv/bin:/home/tomoyan/.cargo/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/home/tomoyan/.local/bin:/home/tomoyan/.local/bin
---- ✂  ----
sys.path = [
    '/home/tomoyan',
    '/usr/lib64/python312.zip',
    '/usr/lib64/python3.12',
    '/usr/lib64/python3.12/lib-dynload',
    '/home/tomoyan/.local/lib/python3.12/site-packages',
    '/usr/lib64/python3.12/site-packages',
    '/usr/lib/python3.12/site-packages',
]
USER_BASE: '/home/tomoyan/.local' (exists)
USER_SITE: '/home/tomoyan/.local/lib/python3.12/site-packages' (exists)
ENABLE_USER_SITE: True

$ pip install --upgrade pip

Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: pip in /usr/lib/python3.12/site-packages (23.2.1)
Collecting pip
  Obtaining dependency information for pip from https://files.pythonhosted.org/packages/8a/6a/19e9fe04fca059ccf770861c7d5721ab4c2aebc539889e97c7977528a53b/pip-24.0-py3-none-any.whl.metadata
  Downloading pip-24.0-py3-none-any.whl.metadata (3.6 kB)
Downloading pip-24.0-py3-none-any.whl (2.1 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.1/2.1 MB 302.4 kB/s eta 0:00:00
Installing collected packages: pip
Successfully installed pip-24.0

$ python3 -m pipx ensurepath

Success! Added /home/tomoyan/.local/bin to the PATH environment variable.

Consider adding shell completions for pipx. Run 'pipx completions' for instructions.

You will need to open a new terminal or re-login for the PATH changes to take effect.

Otherwise pipx is ready to go! ✨ 🌟 ✨

成功! PATH 環境変数に /home/tomoyan/.local/bin を追加しました。

pipx のシェル補完を追加することを検討してください。手順については「pipx completed」を実行してください。

PATH の変更を有効にするには、新しいターミナルを開くか、再ログインする必要があります。

それ以外の場合は、pipx を使用する準備ができています。 ✨ 🌟 ✨

zsh の場合は ~/.zprofilePATH の設定が追加されます。

┌──(tomoyan  WICKED-BEAT)-[~] └─$ cat ~/.zprofile


# Created by `pipx` on 2023-07-23 04:47:06
export PATH="$PATH:/home/tomoyan/.local/bin"

bash の場合は…🤔
~/.profile が優先なディストリビューションでは、それに PATH の設定が追加されます。

$ cat ~/.profile


# Created by `pipx` on 2023-08-03 21:57:19
export PATH="$PATH:/home/dietpi/.local/bin"

~/.bash_profilePATH の設定が追加されます。

$ cat ~/.bash_profile


# Created by `pipx` on 2023-07-23 05:54:36
export PATH="$PATH:/home/tomoyan/.local/bin"

$ ls -al

...
-rw-r--r--  1 dietpi dietpi   161 Dec 16 00:24 .profile

~/.bash_profile ではなく ~/.profile に統一しているディストリビューションでは、~/.bash_profile が存在していないので ~/.profile に設定を追記するべきです。新たに ~/.bash_profile を作成してしまうと元々の ~/.profile が実行されなくなって問題が起きる可能性があります😱

ログイン時のスクリプト実行優先順位は、以下の順番で且つ何れか1つだけが実行されます🤔

~/.bash_profile
~/.bash_login
~/.profile

参考: 【LPIC102】bashの設定ファイルと読み込み順序 LPICで学ぶLinux2 - SEワンタンの独学備忘録

シェルの設定を反映させる。(exec $(which zsh) –login or exec $(which bash) –login …)

$ exec $SHELL -l
$ pipx --version

1.2.0

$ ls -al .bash*

...
-rw-r--r-- 1 tomoyan tomoyan  187  2月  9 04:11 .bash_profile
-rw-r--r-- 1 tomoyan tomoyan  575  2月  8 14:00 .bashrc

.bash_profile または .profile は、ログイン時に1度だけ実行される🤔
.bashrc は、bash 起動時に1度だけ実行される🤔
exec $SHELL -l.bash_profile を適用して bash を起動するが、その bash を終了すると .bash_profile の内容は失われるので再ログインする必要がある🤔

公式: Upgrade pipx - Installation - pipx 翻訳

Fedora

$ python3 -m pip install --user --upgrade pipx

Requirement already satisfied: pipx in ./.local/lib/python3.12/site-packages (1.2.0)
Collecting pipx
  Obtaining dependency information for pipx from https://files.pythonhosted.org/packages/86/80/6b677762cf8f667ad88792e67557df9b11a8f1f2014f9795fb8c3d8a89ab/pipx-1.4.3-py3-none-any.whl.metadata
  Downloading pipx-1.4.3-py3-none-any.whl.metadata (17 kB)
Requirement already satisfied: argcomplete>=1.9.4 in /usr/lib/python3.12/site-packages (from pipx) (2.0.0)
Requirement already satisfied: packaging>=20 in /usr/lib/python3.12/site-packages (from pipx) (23.1)
Requirement already satisfied: platformdirs>=2.1 in ./.local/lib/python3.12/site-packages (from pipx) (3.9.1)
Collecting userpath!=1.9.0,>=1.6 (from pipx)
  Obtaining dependency information for userpath!=1.9.0,>=1.6 from https://files.pythonhosted.org/packages/a2/28/20c7dcdb12681b2e12224184a8a158e5df51feb0c68116cb4b1b991a4aab/userpath-1.9.1-py3-none-any.whl.metadata
  Downloading userpath-1.9.1-py3-none-any.whl.metadata (3.0 kB)
Requirement already satisfied: click in /usr/lib/python3.12/site-packages (from userpath!=1.9.0,>=1.6->pipx) (8.1.3)
Downloading pipx-1.4.3-py3-none-any.whl (65 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 65.1/65.1 kB 457.5 kB/s eta 0:00:00
Downloading userpath-1.9.1-py3-none-any.whl (9.1 kB)
Installing collected packages: userpath, pipx
  Attempting uninstall: userpath
    Found existing installation: userpath 1.9.0
    Uninstalling userpath-1.9.0:
      Successfully uninstalled userpath-1.9.0
  Attempting uninstall: pipx
    Found existing installation: pipx 1.2.0
    Uninstalling pipx-1.2.0:
      Successfully uninstalled pipx-1.2.0
Successfully installed pipx-1.4.3 userpath-1.9.1

公式: Shell Completion - Installation - pipx 翻訳

Fedora

$ python3 -m pipx completions


Add the appropriate command to your shell's config file
so that it is run on startup. You will likely have to restart
or re-login for the autocompletion to start working.

bash:
    eval "$(register-python-argcomplete pipx)"

zsh:
    To activate completions for zsh you need to have
    bashcompinit enabled in zsh:

    autoload -U bashcompinit
    bashcompinit

    Afterwards you can enable completion for pipx:

    eval "$(register-python-argcomplete pipx)"

tcsh:
    eval `register-python-argcomplete --shell tcsh pipx`

fish:
    # Not required to be in the config file, only run once
    register-python-argcomplete --shell fish pipx >~/.config/fish/completions/pipx.fish




適切なコマンドをシェルの構成ファイルに追加します。
起動時に実行されるようにします。おそらく再起動が必要になるでしょう
または、オートコンプリートを機能させるために再ログインしてください。

bash:
    eval "$(register-python-argcomplete pipx)"

zsh:
    zsh の補完を有効にするには、次のものが必要です。
    zsh で bashcompinit を有効にします。

    autoload -U bashcompinit
    bashcompinit

    その後、pipx の補完を有効にできます。

    eval "$(register-python-argcomplete pipx)"

tcsh:
    eval `register-python-argcomplete --shell tcsh pipx`

fish:
    # 構成ファイルに含める必要はなく、一度だけ実行します
    register-python-argcomplete --shellfish pipx >~/.config/fish/completions/pipx.fish



zsh の場合

┌──(tomoyan  WICKED-BEAT)-[~] └─$ echo 'autoload bashcompinit && bashcompinit' >> ~/.zprofile
$ echo 'eval "$(register-python-argcomplete pipx)"' >> ~/.zprofile $ . ~/.zprofile $ pipx -> Tab キーを押す completions -- Print instructions on enabling shell completions for pipx ensurepath -- Ensure directories necessary for pipx operation are in your PATH environment variable. environment -- Print a list of variables used in pipx.constants. --help -h -- show this help message and exit inject -- Install packages into an existing Virtual Environment install -- Install a package list -- List installed packages reinstall -- Reinstall a package reinstall-all -- Reinstall all packages run -- Download the latest version of a package to a temporary virtual environment, then run runpip -- Run pip in an existing pipx-managed Virtual Environment uninject -- Uninstall injected packages from an existing Virtual Environment uninstall -- Uninstall a package uninstall-all -- Uninstall all packages upgrade -- Upgrade a package upgrade-all -- Upgrade all packages. Runs `pip install -U <pkgname>` for each package. --version -- Print version and exit

bash の場合

$ echo 'eval "$(register-python-argcomplete pipx)"' >> ~/.bash_profile
$ . ~/.bash_profile
$ pipx -> Tab キーを押す
--help         completions    inject         reinstall      runpip         uninstall-all
--version      ensurepath     install        reinstall-all  uninject       upgrade
-h             environment    list           run            uninstall      upgrade-all

$ pipx --help

usage: pipx [-h] [--version]
            {install,uninject,inject,upgrade,upgrade-all,uninstall,uninstall-all,reinstall,reinstall-all,list,run,runpip,ensurepath,environment,completions}
            ...

Install and execute apps from Python packages.

Binaries can either be installed globally into isolated Virtual Environments
or run directly in a temporary Virtual Environment.

Virtual Environment location is /home/tomoyan/.local/pipx/venvs.
Symlinks to apps are placed in /home/tomoyan/.local/bin.

optional environment variables:
  PIPX_HOME             Overrides default pipx location. Virtual Environments will be installed to
                        $PIPX_HOME/venvs.
  PIPX_BIN_DIR          Overrides location of app installations. Apps are symlinked or copied here.
  PIPX_DEFAULT_PYTHON   Overrides default python used for commands.
  USE_EMOJI             Overrides emoji behavior. Default value varies based on platform.

options:
  -h, --help            show this help message and exit
  --version             Print version and exit

subcommands:
  Get help for commands with pipx COMMAND --help

  {install,uninject,inject,upgrade,upgrade-all,uninstall,uninstall-all,reinstall,reinstall-all,list,run,runpip,ensurepath,environment,completions}
    install             Install a package
    uninject            Uninstall injected packages from an existing Virtual Environment
    inject              Install packages into an existing Virtual Environment
    upgrade             Upgrade a package
    upgrade-all         Upgrade all packages. Runs `pip install -U <pkgname>` for each package.
    uninstall           Uninstall a package
    uninstall-all       Uninstall all packages
    reinstall           Reinstall a package
    reinstall-all       Reinstall all packages
    list                List installed packages
    run                 Download the latest version of a package to a temporary virtual environment, then
                        run an app from it. Also compatible with local `__pypackages__` directory
                        (experimental).
    runpip              Run pip in an existing pipx-managed Virtual Environment
    ensurepath          Ensure directories necessary for pipx operation are in your PATH environment
                        variable.
    environment         Print a list of variables used in pipx.constants.
    completions         Print instructions on enabling shell completions for pipx

$ pipx install --help

usage: pipx install [-h] [--include-deps] [--verbose] [--force] [--suffix SUFFIX] [--python PYTHON]
                    [--system-site-packages] [--index-url INDEX_URL] [--editable] [--pip-args PIP_ARGS]
                    package_spec

The install command is the preferred way to globally install apps
from python packages on your system. It creates an isolated virtual
environment for the package, then ensures the package's apps are
accessible on your $PATH.

The result: apps you can run from anywhere, located in packages
you can cleanly upgrade or uninstall. Guaranteed to not have
dependency version conflicts or interfere with your OS's python
packages. 'sudo' is not required to do this.

pipx install PACKAGE_NAME
pipx install --python PYTHON PACKAGE_NAME
pipx install VCS_URL
pipx install ./LOCAL_PATH
pipx install ZIP_FILE
pipx install TAR_GZ_FILE

The PACKAGE_SPEC argument is passed directly to `pip install`.

The default virtual environment location is C:\Users\tomoyan\.local\pipx
and can be overridden by setting the environment variable `PIPX_HOME`
(Virtual Environments will be installed to `$PIPX_HOME/venvs`).

The default app location is C:\Users\tomoyan\.local\bin and can be
overridden by setting the environment variable `PIPX_BIN_DIR`.

The default python executable used to install a package is
C:\Users\tomoyan\scoop\apps\python\current\python.exe and can be overridden
by setting the environment variable `PIPX_DEFAULT_PYTHON`.

positional arguments:
  package_spec          package name or pip installation spec

options:
  -h, --help            show this help message and exit
  --include-deps        Include apps of dependent packages
  --verbose
  --force, -f           Modify existing virtual environment and files in PIPX_BIN_DIR
  --suffix SUFFIX       Optional suffix for virtual environment and executable names. NOTE: The suffix feature is
                        experimental and subject to change.
  --python PYTHON       The Python executable used to create the Virtual Environment and run the associated app/apps.
                        Must be v3.6+.
  --system-site-packages
                        Give the virtual environment access to the system site-packages dir.
  --index-url INDEX_URL, -i INDEX_URL
                        Base URL of Python Package Index
  --editable, -e        Install a project in editable mode
  --pip-args PIP_ARGS   Arbitrary pip arguments to pass directly to pip install/upgrade commands

$ pipx inject --help

usage: pipx inject [-h] [--include-apps] [--include-deps] [--system-site-packages] [--index-url INDEX_URL]
                   [--editable] [--pip-args PIP_ARGS] [--force] [--verbose]
                   package dependencies [dependencies ...]

Installs packages to an existing pipx-managed virtual environment.

positional arguments:
  package               Name of the existing pipx-managed Virtual Environment to inject into
  dependencies          the packages to inject into the Virtual Environment--either package name or pip package spec

options:
  -h, --help            show this help message and exit
  --include-apps        Add apps from the injected packages onto your PATH
  --include-deps        Include apps of dependent packages
  --system-site-packages
                        Give the virtual environment access to the system site-packages dir.
  --index-url INDEX_URL, -i INDEX_URL
                        Base URL of Python Package Index
  --editable, -e        Install a project in editable mode
  --pip-args PIP_ARGS   Arbitrary pip arguments to pass directly to pip install/upgrade commands
  --force, -f           Modify existing virtual environment and files in PIPX_BIN_DIR
  --verbose

JupyterLab

JupyterLab3 基本セット

$ pipx install --include-deps --suffix 3 jupyterlab==3.6.5 --pip-args='--only-binary=:all:'

  installed package jupyterlab 3.6.5 (jupyterlab3), installed using Python 3.12.1
  These apps are now globally available
    - ipython3
    - ipython33
    - jlpm3
    - jsonschema3
    - jupyter-bundlerextension3
    - jupyter-dejavu3
    - jupyter-events3
    - jupyter-execute3
    - jupyter-fileid3
    - jupyter-kernel3
    - jupyter-kernelspec3
    - jupyter-lab3
    - jupyter-labextension3
    - jupyter-labhub3
    - jupyter-migrate3
    - jupyter-nbclassic-bundlerextension3
    - jupyter-nbclassic-extension3
    - jupyter-nbclassic-serverextension3
    - jupyter-nbclassic3
    - jupyter-nbconvert3
    - jupyter-nbextension3
    - jupyter-notebook3
    - jupyter-run3
    - jupyter-server3
    - jupyter-serverextension3
    - jupyter-troubleshoot3
    - jupyter-trust3
    - jupyter3
    - normalizer3
    - pybabel3
    - pygmentize3
    - pyjson53
    - send2trash3
    - wsdump3
  These manual pages are now globally available
    - man1/ipython.1
done! ✨ 🌟 ✨

$ pipx inject jupyterlab3 jupyterlab-language-pack-ja-JP jupyterlab-git

  injected package jupyterlab-language-pack-ja-jp into venv jupyterlab3
done! ✨ 🌟 ✨
  injected package jupyterlab-git into venv jupyterlab3
done! ✨ 🌟 ✨

JupyterLab4 基本セット

$ pipx install --include-deps --suffix 4 'jupyterlab>=4.1.0'

  installed package jupyterlab 4.1.0 (jupyterlab4), installed using Python 3.12.1
  These apps are now globally available
    - httpx4
    - ipython34
    - ipython4
    - jlpm4
    - jsonpointer4
    - jsonschema4
    - jupyter-dejavu4
    - jupyter-events4
    - jupyter-execute4
    - jupyter-kernel4
    - jupyter-kernelspec4
    - jupyter-lab4
    - jupyter-labextension4
    - jupyter-labhub4
    - jupyter-migrate4
    - jupyter-nbconvert4
    - jupyter-run4
    - jupyter-server4
    - jupyter-troubleshoot4
    - jupyter-trust4
    - jupyter4
    - normalizer4
    - pybabel4
    - pygmentize4
    - pyjson54
    - send2trash4
    - wsdump4
  These manual pages are now globally available
    - man1/ipython.1
done! ✨ 🌟 ✨

$ pipx inject jupyterlab4 jupyterlab-language-pack-ja-JP jupyterlab-git

  injected package jupyterlab-language-pack-ja-jp into venv jupyterlab4
done! ✨ 🌟 ✨
  injected package jupyterlab-git into venv jupyterlab4
done! ✨ 🌟 ✨

仮想環境一覧

$ pipx list

venvs are in /home/tomoyan/.local/share/pipx/venvs
apps are exposed on your $PATH at /home/tomoyan/.local/bin
manual pages are exposed at /home/tomoyan/.local/share/man
   package jupyterlab 3.6.5 (jupyterlab3), installed using Python 3.12.1
    - ipython3
    - ipython33
    - jlpm3
    - jsonschema3
    - jupyter-bundlerextension3
    - jupyter-dejavu3
    - jupyter-events3
    - jupyter-execute3
    - jupyter-fileid3
    - jupyter-kernel3
    - jupyter-kernelspec3
    - jupyter-lab3
    - jupyter-labextension3
    - jupyter-labhub3
    - jupyter-migrate3
    - jupyter-nbclassic-bundlerextension3
    - jupyter-nbclassic-extension3
    - jupyter-nbclassic-serverextension3
    - jupyter-nbclassic3
    - jupyter-nbconvert3
    - jupyter-nbextension3
    - jupyter-notebook3
    - jupyter-run3
    - jupyter-server3
    - jupyter-serverextension3
    - jupyter-troubleshoot3
    - jupyter-trust3
    - jupyter3
    - normalizer3
    - pybabel3
    - pygmentize3
    - pyjson53
    - send2trash3
    - wsdump3
    - man1/ipython.1 (symlink missing or pointing to unexpected location)
   package jupyterlab 4.1.0 (jupyterlab4), installed using Python 3.12.1
    - httpx4
    - ipython34
    - ipython4
    - jlpm4
    - jsonpointer4
    - jsonschema4
    - jupyter-dejavu4
    - jupyter-events4
    - jupyter-execute4
    - jupyter-kernel4
    - jupyter-kernelspec4
    - jupyter-lab4
    - jupyter-labextension4
    - jupyter-labhub4
    - jupyter-migrate4
    - jupyter-nbconvert4
    - jupyter-run4
    - jupyter-server4
    - jupyter-troubleshoot4
    - jupyter-trust4
    - jupyter4
    - normalizer4
    - pybabel4
    - pygmentize4
    - pyjson54
    - send2trash4
    - wsdump4
    - man1/ipython.1

$ pipx upgrade jupyterlab4

upgraded package jupyterlab4 from 4.0.9 to 4.0.11 (location: /home/tomoyan/.local/pipx/venvs/jupyterlab4)

コマンドライン オプション

起動コマンド 説明
$ jupyter notebook Jupyter Notebook を起動。
$ jupyter-lab JupyterLab を起動。
$ jupyter-lab --no-browser JupyterLab をリモートやヘッドレスマシンなどでブラウザなしで起動。
$ jupyter-lab --ip=0.0.0.0 --no-browser JupyterLab をヘッドレスマシンなどで外部アクセスを許可して起動。
$ jupyter-lab --ip=0.0.0.0 --port=28888 --no-browser JupyterLab 外部アクセス許可+ポート指定して起動。
$ jupyter-lab --version JupyterLab のバージョンを表示。

$ jupyter notebook
$ jupyter-lab3
$ jupyter-lab3 --no-browser
$ jupyter-lab3 --ip=0.0.0.0 --no-browser
$ jupyter-lab3 --ip=0.0.0.0 --port=28888 --no-browser
$ jupyter-lab3 --version
$ jupyter-lab4
$ jupyter-lab4 --no-browser
$ jupyter-lab4 --ip=0.0.0.0 --no-browser
$ jupyter-lab4 --ip=0.0.0.0 --port=28888 --no-browser
$ jupyter-lab4 --version

$ jupyter-lab4 --version

4.0.6

$ pipx inject jupyterlab4 jupyterlab-drawio

  injected package jupyterlab-drawio into venv jupyterlab4
done! ✨ 🌟 ✨

$ jupyter4 --version

Selected Jupyter core packages...
IPython          : 8.21.0
ipykernel        : 6.29.2
ipywidgets       : 8.1.2
jupyter_client   : 8.6.0
jupyter_core     : 5.7.1
jupyter_server   : 2.12.5
jupyterlab       : 3.6.7
nbclient         : 0.9.0
nbconvert        : 7.16.0
nbformat         : 5.9.2
notebook         : 6.5.4
qtconsole        : not installed
traitlets        : 5.14.1

pipx install でインストールしたパッケージを pipx inject でインストールし直す😅

$ pipx inject jupyterlab4 jupyterlab==4.1.3

  injected package jupyterlab into venv jupyterlab4
done! ✨ 🌟 ✨

または、pipx inject する際にバージョンを指定しておく🤔

$ pipx inject jupyterlab4 jupyterlab-drawio jupyterlab==4.1.3

  injected package jupyterlab-drawio into venv jupyterlab4
done! ✨ 🌟 ✨
  injected package jupyterlab into venv jupyterlab4
done! ✨ 🌟 ✨

$ jupyter4 --version

Selected Jupyter core packages...
IPython          : 8.21.0
ipykernel        : 6.29.2
ipywidgets       : 8.1.2
jupyter_client   : 8.6.0
jupyter_core     : 5.7.1
jupyter_server   : 2.12.5
jupyterlab       : 4.1.3
nbclient         : 0.9.0
nbconvert        : 7.16.0
nbformat         : 5.9.2
notebook         : 6.5.4
qtconsole        : not installed
traitlets        : 5.14.1

pipx が仮想環境を正常に作成できないので OS パッケージの venv モジュールをインストールするように指示される。

$ pipx install --suffix 4 jupyterlab==4.0.6                       

The virtual environment was not created successfully because ensurepip is not
available.  On Debian/Ubuntu systems, you need to install the python3-venv
package using the following command.

    apt install python3.11-venv

You may need to use sudo with that command.  After installing the python3-venv
package, recreate your virtual environment.

Failing command: /home/tomoyan/.local/pipx/shared/bin/python3


'/usr/bin/python3 -m venv --clear /home/tomoyan/.local/pipx/shared' failed

指示にしたがって python3.11-venv をインストールすると正常動作する。

$ sudo apt install python3.11-venv

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
  gcc-12-base libarmadillo11 libcodec2-1.1 libgcc-12-dev libgupnp-igd-1.0-4
  libjim0.81 libnfs13 libobjc-12-dev libstdc++-12-dev python3-jdcal
Use 'sudo apt autoremove' to remove them.
The following NEW packages will be installed:
  python3.11-venv
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 5884 B of archives.
After this operation, 28.7 kB of additional disk space will be used.
Get:1 http://ftp.riken.jp/Linux/kali kali-rolling/main amd64 python3.11-venv amd64 3.11.4-1 [5884 B]
Fetched 5884 B in 1s (5166 B/s)     
Selecting previously unselected package python3.11-venv.
(Reading database ... 403866 files and directories currently installed.)
Preparing to unpack .../python3.11-venv_3.11.4-1_amd64.deb ...
Unpacking python3.11-venv (3.11.4-1) ...
Setting up python3.11-venv (3.11.4-1) ...

~/.local/pipx/logs/

$ cat ~/.local/pipx/logs/cmd_2023-08-06_03.18.35_pip_errors.log

PIP STDOUT
----------
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple/
Collecting jupyterlab==3.6.5
  Downloading https://www.piwheels.org/simple/jupyterlab/jupyterlab-3.6.5-py3-none-any.whl (8.9 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 8.9/8.9 MB 538.1 kB/s eta 0:00:00
Collecting ipython (from jupyterlab==3.6.5)
  Downloading https://www.piwheels.org/simple/ipython/ipython-8.14.0-py3-none-any.whl (798 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 798.7/798.7 kB 456.2 kB/s eta 0:00:00
Collecting packaging (from jupyterlab==3.6.5)
  Using cached https://www.piwheels.org/simple/packaging/packaging-23.1-py3-none-any.whl (48 kB)
Collecting tornado>=6.1.0 (from jupyterlab==3.6.5)
  Downloading https://www.piwheels.org/simple/tornado/tornado-6.3.2-cp38-abi3-linux_armv6l.whl (425 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 425.4/425.4 kB 402.8 kB/s eta 0:00:00
Collecting jupyter-core (from jupyterlab==3.6.5)
  Downloading https://www.piwheels.org/simple/jupyter-core/jupyter_core-5.3.1-py3-none-any.whl (93 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 93.7/93.7 kB 166.7 kB/s eta 0:00:00
Collecting jupyterlab-server~=2.19 (from jupyterlab==3.6.5)
  Downloading https://www.piwheels.org/simple/jupyterlab-server/jupyterlab_server-2.24.0-py3-none-any.whl (57 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 57.3/57.3 kB 87.0 kB/s eta 0:00:00
Collecting jupyter-server<3,>=1.16.0 (from jupyterlab==3.6.5)
  Downloading https://www.piwheels.org/simple/jupyter-server/jupyter_server-2.7.0-py3-none-any.whl (375 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 375.1/375.1 kB 275.9 kB/s eta 0:00:00
Collecting jupyter-ydoc~=0.2.4 (from jupyterlab==3.6.5)
  Downloading https://www.piwheels.org/simple/jupyter-ydoc/jupyter_ydoc-0.2.5-py3-none-any.whl (6.2 kB)
Collecting jupyter-server-ydoc~=0.8.0 (from jupyterlab==3.6.5)
  Downloading https://www.piwheels.org/simple/jupyter-server-ydoc/jupyter_server_ydoc-0.8.0-py3-none-any.whl (11 kB)
Collecting nbclassic (from jupyterlab==3.6.5)
  Downloading https://www.piwheels.org/simple/nbclassic/nbclassic-1.0.0-py3-none-any.whl (10.0 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 10.0/10.0 MB 737.4 kB/s eta 0:00:00
Collecting notebook<7 (from jupyterlab==3.6.5)
  Downloading https://www.piwheels.org/simple/notebook/notebook-6.5.5-py3-none-any.whl (529 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 529.8/529.8 kB 374.7 kB/s eta 0:00:00
Collecting jinja2>=2.1 (from jupyterlab==3.6.5)
  Downloading https://www.piwheels.org/simple/jinja2/Jinja2-3.1.2-py3-none-any.whl (133 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 133.1/133.1 kB 157.4 kB/s eta 0:00:00
Collecting tomli (from jupyterlab==3.6.5)
  Downloading https://www.piwheels.org/simple/tomli/tomli-2.0.1-py3-none-any.whl (12 kB)
Collecting MarkupSafe>=2.0 (from jinja2>=2.1->jupyterlab==3.6.5)
  Downloading https://www.piwheels.org/simple/markupsafe/MarkupSafe-2.1.3-cp39-cp39-linux_armv6l.whl (23 kB)
Collecting anyio>=3.1.0 (from jupyter-server<3,>=1.16.0->jupyterlab==3.6.5)
  Downloading https://www.piwheels.org/simple/anyio/anyio-3.7.1-py3-none-any.whl (80 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 80.9/80.9 kB 135.9 kB/s eta 0:00:00
Collecting argon2-cffi (from jupyter-server<3,>=1.16.0->jupyterlab==3.6.5)
  Using cached https://www.piwheels.org/simple/argon2-cffi/argon2_cffi-21.3.0-py3-none-any.whl (14 kB)
Collecting jupyter-client>=7.4.4 (from jupyter-server<3,>=1.16.0->jupyterlab==3.6.5)
  Downloading https://www.piwheels.org/simple/jupyter-client/jupyter_client-8.3.0-py3-none-any.whl (103 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 103.2/103.2 kB 146.2 kB/s eta 0:00:00
Collecting jupyter-events>=0.6.0 (from jupyter-server<3,>=1.16.0->jupyterlab==3.6.5)
  Downloading https://www.piwheels.org/simple/jupyter-events/jupyter_events-0.7.0-py3-none-any.whl (18 kB)
Collecting jupyter-server-terminals (from jupyter-server<3,>=1.16.0->jupyterlab==3.6.5)
  Downloading https://www.piwheels.org/simple/jupyter-server-terminals/jupyter_server_terminals-0.4.4-py3-none-any.whl (13 kB)
Collecting nbconvert>=6.4.4 (from jupyter-server<3,>=1.16.0->jupyterlab==3.6.5)
  Downloading https://www.piwheels.org/simple/nbconvert/nbconvert-7.7.3-py3-none-any.whl (254 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 254.7/254.7 kB 239.2 kB/s eta 0:00:00
Collecting nbformat>=5.3.0 (from jupyter-server<3,>=1.16.0->jupyterlab==3.6.5)
  Downloading https://www.piwheels.org/simple/nbformat/nbformat-5.9.2-py3-none-any.whl (77 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 77.6/77.6 kB 118.7 kB/s eta 0:00:00
Collecting overrides (from jupyter-server<3,>=1.16.0->jupyterlab==3.6.5)
  Downloading https://www.piwheels.org/simple/overrides/overrides-7.3.1-py3-none-any.whl (17 kB)
Collecting prometheus-client (from jupyter-server<3,>=1.16.0->jupyterlab==3.6.5)
  Downloading https://www.piwheels.org/simple/prometheus-client/prometheus_client-0.17.1-py3-none-any.whl (60 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 60.6/60.6 kB 122.7 kB/s eta 0:00:00
Collecting pyzmq>=24 (from jupyter-server<3,>=1.16.0->jupyterlab==3.6.5)
  Downloading https://www.piwheels.org/simple/pyzmq/pyzmq-25.1.0-cp39-cp39-linux_armv6l.whl (6.6 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 6.6/6.6 MB 774.3 kB/s eta 0:00:00
Collecting send2trash (from jupyter-server<3,>=1.16.0->jupyterlab==3.6.5)
  Downloading https://www.piwheels.org/simple/send2trash/Send2Trash-1.8.2-py3-none-any.whl (18 kB)
Collecting terminado>=0.8.3 (from jupyter-server<3,>=1.16.0->jupyterlab==3.6.5)
  Downloading https://www.piwheels.org/simple/terminado/terminado-0.17.1-py3-none-any.whl (17 kB)
Collecting traitlets>=5.6.0 (from jupyter-server<3,>=1.16.0->jupyterlab==3.6.5)
  Downloading https://www.piwheels.org/simple/traitlets/traitlets-5.9.0-py3-none-any.whl (117 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 117.4/117.4 kB 209.1 kB/s eta 0:00:00
Collecting websocket-client (from jupyter-server<3,>=1.16.0->jupyterlab==3.6.5)
  Downloading https://www.piwheels.org/simple/websocket-client/websocket_client-1.6.1-py3-none-any.whl (56 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 56.9/56.9 kB 171.6 kB/s eta 0:00:00
Collecting platformdirs>=2.5 (from jupyter-core->jupyterlab==3.6.5)
  Downloading https://www.piwheels.org/simple/platformdirs/platformdirs-3.10.0-py3-none-any.whl (17 kB)
Collecting jupyter-server-fileid<1,>=0.6.0 (from jupyter-server-ydoc~=0.8.0->jupyterlab==3.6.5)
  Downloading https://www.piwheels.org/simple/jupyter-server-fileid/jupyter_server_fileid-0.9.0-py3-none-any.whl (15 kB)
Collecting ypy-websocket<0.9.0,>=0.8.2 (from jupyter-server-ydoc~=0.8.0->jupyterlab==3.6.5)
  Downloading https://www.piwheels.org/simple/ypy-websocket/ypy_websocket-0.8.4-py3-none-any.whl (10 kB)
Collecting importlib-metadata>=3.6 (from jupyter-ydoc~=0.2.4->jupyterlab==3.6.5)
  Downloading https://www.piwheels.org/simple/importlib-metadata/importlib_metadata-6.8.0-py3-none-any.whl (22 kB)
Collecting y-py<0.7.0,>=0.6.0 (from jupyter-ydoc~=0.2.4->jupyterlab==3.6.5)
  Downloading y_py-0.6.0.tar.gz (52 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 52.9/52.9 kB 556.9 kB/s eta 0:00:00
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'done'
  Preparing metadata (pyproject.toml): started
  Preparing metadata (pyproject.toml): finished with status 'error'

PIP STDERR
----------
  WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))': /simple/jupyterlab/jupyterlab-3.6.5-py3-none-any.whl
  error: subprocess-exited-with-error
  
  × Preparing metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [3 lines of output]
      Error running maturin: Command '['maturin', 'pep517', 'write-dist-info', '--metadata-directory', '/tmp/pip-modern-metadata-_dgl_ar0', '--interpreter', '/home/dietpi/.local/pipx/venvs/jupyterlab3/bin/python']' died with <Signals.SIGILL: 4>.
      Checking for Rust toolchain....
      Running `maturin pep517 write-dist-info --metadata-directory /tmp/pip-modern-metadata-_dgl_ar0 --interpreter /home/dietpi/.local/pipx/venvs/jupyterlab3/bin/python`
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
dietpi@dietpi-001:~$ pipx install --suffix 3 jupyterlab==3.6.5
Fatal error from pip prevented installation. Full pip output in file:
    /home/dietpi/.local/pipx/logs/cmd_2023-08-06_03.31.19_pip_errors.log

pip seemed to fail to build package:
    y-py<0.7.0,>=0.6.0

Some possibly relevant errors from pip install:
    error: subprocess-exited-with-error
    error: metadata-generation-failed

Error installing jupyterlab from spec 'jupyterlab==3.6.5'.

$ pip install y-py --user

Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple/
Collecting y-py
  Using cached y_py-0.6.0.tar.gz (52 kB)
  Installing build dependencies ... -⌫ ⌫\⌫ ⌫|⌫ ⌫/⌫ ⌫-⌫ ⌫\⌫ ⌫|⌫ ⌫done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... -⌫ ⌫error
  error: subprocess-exited-with-error
  
  × Preparing metadata (pyproject.toml) did not run successfully.
   exit code: 1
  ╰─> [3 lines of output]
      Error running maturin: Command '['maturin', 'pep517', 'write-dist-info', '--metadata-directory', '/tmp/pip-modern-metadata-0iw3tc63', '--interpreter', '/usr/bin/python3']' died with <Signals.SIGILL: 4>.
      Checking for Rust toolchain....
      Running `maturin pep517 write-dist-info --metadata-directory /tmp/pip-modern-metadata-0iw3tc63 --interpreter /usr/bin/python3`
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

$ tmux

zsh: compdef: コマンドが見つかりませんでした...

~/.zprofileautoload -Uz compinit && compinit を追加する🤔

$ nano ~/.zprofile

# Created by `pipx` on 2024-02-02 08:14:31
export PATH="$PATH:/home/tomoyan/.local/bin"
autoload -Uz compinit && compinit
autoload bashcompinit && bashcompinit
eval "$(register-python-argcomplete pipx)"

システムの Python バージョンがマイナーアップデート (3.11 → 3.12) すると、モジュールが参照できなくなる😝

$ pipx

Traceback (most recent call last):
  File "/home/tomoyan/.local/bin/pipx", line 5, in <module>
    from pipx.main import cli
ModuleNotFoundError: No module named 'pipx'

$ python -m site

sys.path = [
    '/home/tomoyan/.local',
    '/usr/lib64/python312.zip',
    '/usr/lib64/python3.12',
    '/usr/lib64/python3.12/lib-dynload',
    '/usr/lib64/python3.12/site-packages',
    '/usr/lib/python3.12/site-packages',
]
USER_BASE: '/home/tomoyan/.local' (exists)
USER_SITE: '/home/tomoyan/.local/lib/python3.12/site-packages' (doesn't exist)
ENABLE_USER_SITE: True

$ ll ~/.local/lib 

合計 0
drwxr-xr-x 1 tomoyan tomoyan  26  3月 16  2023 python3.11

USER_SITE の (doesn't exist) を直す😅

※python3.11 → python3.12 のシンボルリンクを張る🤔

$ cd ~/.local/lib
$ ln -s python3.11 python3.12
$ ll

合計 4
drwxr-xr-x 1 tomoyan tomoyan  26  3月 16  2023 python3.11
lrwxrwxrwx 1 tomoyan tomoyan  10  2月  5 07:05 python3.12 -> python3.11
$ python -m site

sys.path = [
    '/home/tomoyan/.local/lib',
    '/usr/lib64/python312.zip',
    '/usr/lib64/python3.12',
    '/usr/lib64/python3.12/lib-dynload',
    '/home/tomoyan/.local/lib/python3.12/site-packages',
    '/usr/lib64/python3.12/site-packages',
    '/usr/lib/python3.12/site-packages',
]
USER_BASE: '/home/tomoyan/.local' (exists)
USER_SITE: '/home/tomoyan/.local/lib/python3.12/site-packages' (exists)
ENABLE_USER_SITE: True

これで一応 pipx は動作するのだが…🥱

$ pipx          

usage: pipx [-h] [--version]
            {install,uninject,inject,upgrade,upgrade-all,uninstall,uninstall-all,reinstall,reinstall-all,list,run,runpip,ensurepath,environment,completions}
            ...

Install and execute apps from Python packages.

Binaries can either be installed globally into isolated Virtual Environments
or run directly in a temporary Virtual Environment.

Virtual Environment location is /home/tomoyan/.local/pipx/venvs.
Symlinks to apps are placed in /home/tomoyan/.local/bin.

optional environment variables:
  PIPX_HOME             Overrides default pipx location. Virtual Environments will be installed to
                        $PIPX_HOME/venvs.
  PIPX_BIN_DIR          Overrides location of app installations. Apps are symlinked or copied here.
  PIPX_DEFAULT_PYTHON   Overrides default python used for commands.
  USE_EMOJI             Overrides emoji behavior. Default value varies based on platform.

options:
  -h, --help            show this help message and exit
  --version             Print version and exit

subcommands:
  Get help for commands with pipx COMMAND --help

  {install,uninject,inject,upgrade,upgrade-all,uninstall,uninstall-all,reinstall,reinstall-all,list,run,runpip,ensurepath,environment,completions}
    install             Install a package
    uninject            Uninstall injected packages from an existing Virtual Environment
    inject              Install packages into an existing Virtual Environment
    upgrade             Upgrade a package
    upgrade-all         Upgrade all packages. Runs `pip install -U <pkgname>` for each package.
    uninstall           Uninstall a package
    uninstall-all       Uninstall all packages
    reinstall           Reinstall a package
    reinstall-all       Reinstall all packages
    list                List installed packages
    run                 Download the latest version of a package to a temporary virtual environment, then
                        run an app from it. Also compatible with local `__pypackages__` directory
                        (experimental).
    runpip              Run pip in an existing pipx-managed Virtual Environment
    ensurepath          Ensure directories necessary for pipx operation are in your PATH environment
                        variable.
    environment         Print a list of variables used in pipx.constants.
    completions         Print instructions on enabling shell completions for pipx

現在の python バージョンは 3.12.1 なので、3.11 で作られた pipx 内部の仮想環境もすべて動作しない😅

$ python -V

Python 3.12.1

$ pipx list

venvs are in /home/tomoyan/.local/pipx/venvs
apps are exposed on your $PATH at /home/tomoyan/.local/bin
   package jupyterlab 3.6.5 (jupyterlab3), installed using Python 3.11.4

    - jlpm3
    - jupyter-lab3
    - jupyter-labextension3
    - jupyter-labhub3
   package jupyterlab 4.0.11 (jupyterlab4), installed using Python 3.11.5
    - jlpm4
    - jupyter-lab4
    - jupyter-labextension4
    - jupyter-labhub4

動作しないし更新もできない😅

$ jupyter-lab4 --ip=0.0.0.0 --no-browser

Traceback (most recent call last):
  File "/home/tomoyan/.local/bin/jupyter-lab4", line 5, in <module>
    from jupyterlab.labapp import main
ModuleNotFoundError: No module named 'jupyterlab'

$ pipx upgrade jupyterlab4

/home/tomoyan/.local/pipx/venvs/jupyterlab4/bin/python: No module named pip
'/home/tomoyan/.local/pipx/venvs/jupyterlab4/bin/python -m pip --no-input install --upgrade jupyterlab -q'
failed

仮想環境のインポートフックを直す😅

python 3.12 であっても古いバージョンで作成された仮想環境は、インポートフックが python 3.11 のままである🤔

$ ll ~/.local/pipx/venvs/jupyterlab4/lib/python3.12/site-packages/*.pth

-rw-r--r-- 1 tomoyan tomoyan 62  9月 23 12:57 /home/tomoyan/.local/pipx/venvs/jupyterlab4/lib/python3.12/site-packages/pipx_shared.pth

$ cat ~/.local/pipx/venvs/jupyterlab4/lib/python3.12/site-packages/pipx_shared.pth

/home/tomoyan/.local/pipx/shared/lib/python3.11/site-packages

pipx の shared/lib の python3.11 → python3.12 へのシンボルリンクを張る🤔

$ cd ~/.local/pipx/shared/lib/
$ ll

合計 0
drwxr-xr-x 1 tomoyan tomoyan 26  2月  5 14:21 python3.12

$ ln -s python3.12 python3.11

これで古いバージョンで作成された仮想環境の site が修正される😍

$ ~/.local/pipx/venvs/jupyterlab4/bin/python -m site

sys.path = [
    '/home/tomoyan/.local/pipx/shared/lib',
    '/usr/lib64/python312.zip',
    '/usr/lib64/python3.12',
    '/usr/lib64/python3.12/lib-dynload',
    '/home/tomoyan/.local/pipx/venvs/jupyterlab4/lib64/python3.12/site-packages',
    '/home/tomoyan/.local/pipx/shared/lib/python3.11/site-packages',
    '/home/tomoyan/.local/pipx/venvs/jupyterlab4/lib/python3.12/site-packages',
]
USER_BASE: '/home/tomoyan/.local' (exists)
USER_SITE: '/home/tomoyan/.local/lib/python3.12/site-packages' (exists)
ENABLE_USER_SITE: False

pipx upgrade も動作する😍

$ pipx upgrade jupyterlab4

upgraded package jupyterlab4 from 4.0.11 to 4.0.12 (location: /home/tomoyan/.local/pipx/venvs/jupyterlab4)
$ pipx list

venvs are in /home/tomoyan/.local/pipx/venvs
apps are exposed on your $PATH at /home/tomoyan/.local/bin
manual pages are exposed at /home/tomoyan/.local/share/man
   package jupyterlab 3.6.5 (jupyterlab3), installed using Python 3.11.4
    - jlpm3
    - jupyter-lab3
    - jupyter-labextension3
    - jupyter-labhub3
   package jupyterlab 4.1.0 (jupyterlab4), installed using Python 3.11.5
    - jlpm4
    - jupyter-lab4
    - jupyter-labextension4
    - jupyter-labhub4

No module named pip · Issue #278 · pypa/pipx 翻訳

$ pipx install --suffix 4 jupyterlab==4.0.6

Fatal error from pip prevented installation. Full pip output in file:
    /home/dietpi/.local/pipx/logs/cmd_2023-10-09_17.33.05_pip_errors.log

Error installing jupyterlab from spec 'jupyterlab==4.0.6'.

$ cat /home/dietpi/.local/pipx/logs/cmd_2023-10-09_17.33.05_pip_errors.log

PIP STDOUT
----------

PIP STDERR
----------
/home/dietpi/.local/pipx/venvs/jupyterlab4/bin/python: No module named pip

~/.local/pipx 削除して pipx を再インストールしてみる🤔

$ rm -rf ~/.local/pipx


$ python3 -m pip install --user -U pipx

Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple/
Requirement already satisfied: pipx in ./.local/lib/python3.11/site-packages (1.2.0)
Requirement already satisfied: argcomplete>=1.9.4 in ./.local/lib/python3.11/site-packages (from pipx) (3.1.1)
Requirement already satisfied: packaging>=20.0 in ./.local/lib/python3.11/site-packages (from pipx) (23.1)
Requirement already satisfied: userpath>=1.6.0 in ./.local/lib/python3.11/site-packages (from pipx) (1.9.0)
Requirement already satisfied: click in ./.local/lib/python3.11/site-packages (from userpath>=1.6.0->pipx) (8.1.6)

そして、再実行する🥰

$ pipx install --suffix 4 jupyterlab==4.0.6

  installed package jupyterlab 4.0.6 (jupyterlab4), installed using Python 3.11.2
  These apps are now globally available
    - jlpm4
    - jupyter-lab4
    - jupyter-labextension4
    - jupyter-labhub4
done! ✨ 🌟 ✨

ビルドに失敗する😔

$ pipx inject jupyterlab4 jupyterlab-drawio jupyter-bokeh 

Fatal error from pip prevented installation. Full pip output in file:
    /home/tomoyan/.local/pipx/logs/cmd_2024-02-07_22.18.11_pip_errors.log

pip failed to build package:
    pyzmq

Some possibly relevant errors from pip install:
    error: subprocess-exited-with-error
    error: command '/usr/bin/g++' failed with exit code 1
Error installing jupyterlab-drawio.

ビルド不要なバイナリであるwheelsを強制(--pip-args='--only-binary=:all:')して再実行する😉

$ pipx inject jupyterlab4 jupyterlab-drawio jupyter-bokeh --pip-args='--only-binary=:all:'

  injected package jupyterlab-drawio into venv jupyterlab4
done! ✨ 🌟 ✨
  injected package jupyter-bokeh into venv jupyterlab4
done! ✨ 🌟 ✨

$ pipx install --include-deps --suffix 3 jupyterlab==3.6.5

Fatal error from pip prevented installation. Full pip output in file:
    /home/tomoyan/.local/state/pipx/log/cmd_2024-02-07_19.02.24_pip_errors.log

pip failed to build package:
    pyzmq

Some possibly relevant errors from pip install:
    error: subprocess-exited-with-error
    error: command '/usr/bin/g++' failed with exit code 1

Error installing jupyterlab from spec 'jupyterlab==3.6.5'.

上記の cmd_xxx_pip_errors.log を確認する🤔

$ cat /home/tomoyan/.local/state/pipx/log/cmd_2024-02-07_19.02.24_pip_errors.log

      g++ -std=c++11 -fno-strict-overflow -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -fexceptions -fcf-protection -fexceptions -fcf-protection -fexceptions -fcf-protection -fPIC -DZMQ_HAVE_CURVE=1 -DZMQ_USE_TWEETNACL=1 -DZMQ_USE_EPOLL=1 -DZMQ_IOTHREADS_USE_EPOLL=1 -DZMQ_POLL_BASED_ON_POLL=1 -Ibundled/zeromq/include -Ibundled -I/home/tomoyan/.local/share/pipx/venvs/jupyterlab3/include -I/usr/include/python3.12 -c buildutils/initlibzmq.cpp -o build/temp.linux-x86_64-cpython-312/buildutils/initlibzmq.o
      buildutils/initlibzmq.cpp:10:10: 致命的エラー: Python.h: そのようなファイルやディレクトリはありません
         10 | #include "Python.h"
            |          ^~~~~~~~~~
      コンパイルを停止しました。
      ************************************************
      ************************************************
      ************************************************
      error: command '/usr/bin/g++' failed with exit code 1
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for pyzmq
ERROR: Could not build wheels for pyzmq, which is required to install pyproject.toml-based projects

python3-devel パッケージをインストールする🤔

$ sudo dnf install python3-devel -y

メタデータの期限切れの最終確認: 1:51:47 前の 2024年02月07日 17時24分51秒 に実施しました。
依存関係が解決しました。
==============================================================================================================
 パッケージ                         アーキテクチャー   バージョン                   リポジトリー        サイズ
==============================================================================================================
インストール:
 python3-devel                      x86_64             3.12.1-2.fc39                updates             312 k
依存関係のインストール:
 pyproject-rpm-macros               noarch             1.12.0-1.fc39                updates              41 k
 python3-rpm-generators             noarch             14-7.fc39                    fedora               30 k
 python3-rpm-macros                 noarch             3.12-4.fc39                  fedora               14 k

トランザクションの概要
==============================================================================================================
インストール  4 パッケージ

ダウンロードサイズの合計: 397 k
インストール後のサイズ: 1.4 M
パッケージのダウンロード:
(1/4): python3-rpm-generators-14-7.fc39.noarch.rpm                             83 kB/s |  30 kB     00:00    
(2/4): python3-rpm-macros-3.12-4.fc39.noarch.rpm                               34 kB/s |  14 kB     00:00    
(3/4): pyproject-rpm-macros-1.12.0-1.fc39.noarch.rpm                           90 kB/s |  41 kB     00:00    
(4/4): python3-devel-3.12.1-2.fc39.x86_64.rpm                                 787 kB/s | 312 kB     00:00    
--------------------------------------------------------------------------------------------------------------
合計                                                                          116 kB/s | 397 kB     00:03     
トランザクションの確認を実行中
トランザクションの確認に成功しました。
トランザクションのテストを実行中
トランザクションのテストに成功しました。
トランザクションを実行中
  準備             :                                                                                      1/1 
  インストール中   : python3-rpm-macros-3.12-4.fc39.noarch                                                1/4 
  インストール中   : pyproject-rpm-macros-1.12.0-1.fc39.noarch                                            2/4 
  インストール中   : python3-rpm-generators-14-7.fc39.noarch                                              3/4 
  インストール中   : python3-devel-3.12.1-2.fc39.x86_64                                                   4/4 
  scriptletの実行中: python3-devel-3.12.1-2.fc39.x86_64                                                   4/4 
  検証             : python3-rpm-generators-14-7.fc39.noarch                                              1/4 
  検証             : python3-rpm-macros-3.12-4.fc39.noarch                                                2/4 
  検証             : pyproject-rpm-macros-1.12.0-1.fc39.noarch                                            3/4 
  検証             : python3-devel-3.12.1-2.fc39.x86_64                                                   4/4 

インストール済み:
  pyproject-rpm-macros-1.12.0-1.fc39.noarch               python3-devel-3.12.1-2.fc39.x86_64                 
  python3-rpm-generators-14-7.fc39.noarch                 python3-rpm-macros-3.12-4.fc39.noarch              

完了しました!

pipx を再実行する😉

$ pipx install --include-deps --suffix 3 jupyterlab==3.6.5


  • python/pipx.txt
  • 最終更新: 2024/03/28 03:30
  • by ともやん