下記は Windows 11 のネイティブの環境にインストールしたときのメモである。その後、この Windows の Swift の挙動がおかしいので、 しかたなくアンインストールし、かわりに WSL2 の Ubuntu 22.04 で入れている。
次の環境でインストールした。
OS: Windows 11 Home Version 10.0.22621
Tool Chain: Swift 5.7.1
IDE: Visual Studio 2022 Community
参考:
https://zenn.dev/kok_i/articles/df8f9fb978780b
私はひねくれものだから、Macintosh でもなく Linux でもなく Windows ネイティブ、 つまり Windows Subsystem for Linux も Docker も使わずに Swift を使ってみることにした。 Swift のバージョンは 5.7.1 である。
p.8 では REPL (Read-Eval-Print Loop) は単に swift コマンドだけで実行できるように書かれているが、 私の環境では単に swift と入力すると次の表示が出て終了する。
Welcome to Swift! Subcommands: swift build Build Swift packages swift package Create and work on packages swift run Run a program from a package swift test Run package tests swift repl Experiment with Swift code interactively Use `swift --help` for descriptions of available options and flags. Use `swift help >subcommand>` for more information about a subcommand.
そこで swift repl としてみると、すぐにプロンプトが返ってきてしまう。
python310.dll が見つからないため、コードの実行を続行できません。
私が入れている Python の環境は Python 3.9.15 である。ううむ、3.10 にバージョンアップしなければならないのか。
C:> conda install python=3.10 Collecting package metadata (current_repodata.json): done Solving environment: failed with initial frozen solve. Retrying with flexible solve. Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source. Collecting package metadata (repodata.json): done Solving environment: failed with initial frozen solve. Retrying with flexible solve. Solving environment: failed CondaError: KeyboardInterrupt バッチ ジョブを終了しますか (Y/N)? Y
しかたがない。新しい環境にした
C:> conda create --name py10 python=3.10 Collecting package metadata (current_repodata.json): done Solving environment: done ## Package Plan ## environment location: C:\Users\username\anaconda3\envs\py10 added / updated specs: - python=3.10 The following packages will be downloaded: package | build ---------------------------|----------------- certifi-2022.12.7 | py310haa95532_0 149 KB libffi-3.4.2 | hd77b12b_6 109 KB pip-22.3.1 | py310haa95532_0 2.8 MB python-3.10.8 | h966fe2a_1 15.8 MB setuptools-65.5.0 | py310haa95532_0 1.2 MB wincertstore-0.2 | py310haa95532_2 15 KB ------------------------------------------------------------ Total: 20.0 MB The following NEW packages will be INSTALLED: done # # To activate this environment, use # # $ conda activate py10 # # To deactivate an active environment, use # # $ conda deactivate C:> conda activate py10 (py10) C:> python --version Python 3.10.8 (py10) C:> swift repl Python path configuration: PYTHONHOME = (not set) PYTHONPATH = (not set) program name = 'python' isolated = 0 environment = 1 user site = 1 import site = 1 sys._base_executable = 'C:\\Library\\Developer\\Toolchains\\unknown-Asserts-development.xctoolchain\\usr\\bin\\lldb.exe' sys.base_prefix = 'C:\\Users\\username\\anaconda3\\envs\\py10' sys.base_exec_prefix = 'C:\\Users\\username\\anaconda3\\envs\\py10' sys.platlibdir = 'lib' sys.executable = 'C:\\Library\\Developer\\Toolchains\\unknown-Asserts-development.xctoolchain\\usr\\bin\\lldb.exe' sys.prefix = 'C:\\Users\\username\\anaconda3\\envs\\py10' sys.exec_prefix = 'C:\\Users\\username\\anaconda3\\envs\\py10' sys.path = [ 'C:\\Users\\username\\anaconda3\\envs\\py10\\python310.zip', '.\\DLLs', '.\\lib', 'C:\\Library\\Developer\\Toolchains\\unknown-Asserts-development.xctoolchain\\usr\\bin', ] Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding Python runtime state: core initialized ModuleNotFoundError: No module named 'encodings' Current thread 0x000051d4 (most recent call first): <no Python frame>
まりんきょ学問所 > コンピュータの部屋 > コンピュータの本 > Swift