Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Pythonランチャーを使ってみよう

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest. →
yuuuka
April 10, 2024

 Pythonランチャーを使ってみよう

PyLadies Tokyo Meetup #90 Python入学式にて発表予定のLTの資料

yuuuka

April 10, 2024

Transcript

22 slides
  1. Pythonランチャーとは Windows プラットフォーム上で複数の Python インストールを管理 し、適切なバージョンの Python インタプリタを実行するためのツー ルです。Python ランチャーは

    Python をインストールすると一緒に インストールされ、通常は Python のバージョンと関連付けられた 拡張子(.py)の関連付けを行います。 By ChatGPT(GPT-3.5)
  2. Pythonランチャーでできること 1. 複数バージョンのサポート : Windows に複数の Python バージョンがインストールされている場合、 Python ランチャーは各スクリプトがどのバージョンの

    Python インタプリタを使用するかを選択するため の仕組みを提供します。 2. スクリプト指定のバージョン管理 : スクリプト自体の shebang 行 (例: `#!/usr/bin/env python`) で特定の Python バージョンを指定している場合、 Python ランチャーはそれに従って適切なバージョンの Python インタプリタを選択します。 3. バージョン指定の実行: コマンドラインから直接 Python バージョンを指定して実行することができま す。例えば、`py -3.8 script.py` とすることで Python 3.8 を使用してスクリプトを実行できます。 4. 環境変数 PYTHONPY: 環境変数 PYTHONPY を設定することで、デフォルトの Python バージョンや振る 舞いをカスタマイズすることができます。
  3. Python 3.12でアップデートされたエラーログ の検証(Python 3.11の場合) $ py -3.11 Python 3.11.7 (tags/v3.11.7:fa7a6f2,

    Dec 4 2023, 19:24:49) [MSC v.1937 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> 故意にNameErrorとSyntaxErrorを出力させてみる
  4. Python 3.12でアップデートされたエラーログ の検証(Python 3.11の場合) >>> sys.version_info Traceback (most recent call

    last): File "<stdin>", line 1, in <module> NameError: name 'sys' is not defined >>> ①故意にNameErrorを出力させてみる
  5. Python 3.12でアップデートされたエラーログ の検証(Python 3.11の場合) >>> print(f"{abc def}") File "<stdin>", line

    1 (abc def) ^^^ SyntaxError: f-string: invalid syntax >>> ②故意にSyntaxErrorを出力させてみる
  6. Python 3.12でアップデートされたエラーログ の検証(Python 3.12の場合) $ py -3.12 Python 3.12.0 (tags/v3.12.0:0fb18b0,

    Oct 2 2023, 13:03:39) [MSC v.1935 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> 故意にNameErrorとSyntaxErrorを出力させてみる
  7. Python 3.12でアップデートされたエラーログ の検証(Python 3.12の場合) >>> sys.version_info Traceback (most recent call

    last): File "<stdin>", line 1, in <module> NameError: name 'sys' is not defined. Did you forget to import 'sys'? >>> ①故意にNameErrorを出力させてみる
  8. Python 3.12でアップデートされたエラーログ の検証(Python 3.12の場合) >>> print(f"{abc def}") File "<stdin>", line

    1 print(f"{abc def}") ^^^ SyntaxError: f-string: expecting '=', or '!', or ':', or '}' >>> ②故意にSyntaxErrorを出力させてみる
  9. それぞれのバージョンのPythonに違うバージョン のライブラリをインストールしてみる • それぞれのバージョンのPythonにパッケージをインストール する py -(動かしたいバージョン) -m pip install

    ◦◦というように指 定することができます。 • バージョンを指定してライブラリをインストールしたい場合は py -(動かしたいバージョン) -m pip install ◦◦==(バージョン)と いうように記述すればインストールができます。
  10. numpy 2.0.0b1でアップデートされた機能の検証 (Python 3.11&numpy 1.26.4の場合) $ py -3.11 Python 3.11.7

    (tags/v3.11.7:fa7a6f2, Dec 4 2023, 19:24:49) [MSC v.1937 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import numpy as np >>> print(np.__version__) 1.26.4 StringDTypeを使ってみる
  11. numpy 2.0.0b1でアップデートされた機能の検 証(Python 3.11&numpy 1.26.4の場合) >>> from numpy.dtypes import StringDType

    Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: cannot import name 'StringDType' from 'numpy.dtypes' (C:\Users\yuuuka\AppData\Local\Programs\Python\Python311\Lib\ site-packages\numpy\dtypes.py) >>> StringDTypeを使ってみる
  12. numpy 2.0.0b1でアップデートされた機能の検証 (Python 3.12&numpy 2.0.0b1の場合) $ py -3.12 Python 3.12.0

    (tags/v3.12.0:0fb18b0, Oct 2 2023, 13:03:39) [MSC v.1935 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import numpy as np >>> print(np.__version__) 2.0.0b1 StringDTypeを使ってみる
  13. numpy 2.0.0b1でアップデートされた機能の検証 (Python 3.12&numpy 2.0.0b1の場合) >>> from numpy.dtypes import StringDType

    >>> data = ["this is a longer string", "short string"] >>> arr = np.array(data, dtype=StringDType()) >>> arr array(['this is a longer string', 'short string'], dtype=StringDType()) >>> StringDTypeを使ってみる

More Decks by yuuuka

Other Decks in Programming