[Python / evogym] 「Python ではじめるオープンエンドな進化的アルゴリズム」で用いる evogym での pip install に失敗する時の対策

インストールしようとしていたのはこれ。

https://github.com/EvolutionGym/evogym

# 1. 環境

以下の環境で作業を行いました。

item|value
--|--
Machine|MacBookPro
OS|MacOS Ventura13.6
CPU|Apple M2
Python|3.10.11

# 2. 結論

結論だけあればいいんじゃい！！という方のために先に結論を書きました。

## 2-1. requirements.txt 修正

以下のように `requirements.txt` を修正して、

```diff:requirements.txt
+Cython==3.0.4
 glfw==2.5.0
 GPy==1.10.0
 GPyOpt @ git+https://github.com/yunshengtian/GPyOpt@5fc1188ffdefea9a3bc7964a9414d4922603e904
 gym==0.22.0
-h5py==3.6.0
+h5py==3.10.0
 imageio==2.14.1
 matplotlib==3.5.1
 neat-python @ git+https://github.com/yunshengtian/neat-python@2762ab630838520ca6c03a866e8a158f592b0370
 numpy==1.21.5
 opencv-python==4.5.5.62
 Pillow==9.0.0
 pybind11==2.9.0
 pygifsicle==1.0.5
-PyOpenGL==3.1.5
-PyOpenGL-accelerate==3.1.5
-torch==1.10.2
+PyOpenGL @ git+https://github.com/mcfletch/pyopengl.git@release-3.1.8#egg=PyOpenGL
+PyOpenGL_accelerate @ git+https://github.com/mcfletch/pyopengl.git@release-3.1.8#egg=PyOpenGL_accelerate&subdirectory=accelerate
+torch==1.12.1
 ttkbootstrap==1.5.1
 typing==3.7.4.3
```

## 2-2. 書籍の公式サイトの手順に従う

以下の記事の、

https://oreilly-japan.github.io/OpenEndedCodebook/app6/

> macOSへのインストール手順

に従って作業すればOK。

上記 requirements.txt 変更点それぞれの理由などを知りたい人は「3.」も読んでみてください。

## 補足

もしかしたら、

```bash
$ brew install hdf5
$ export HDF5_DIR="$(brew --prefix hdf5)"
```

も必要かもしれないけれど、おそらく必要ないです。
色々やってみたけど、それでも引っかかって動かなかった時に、念の為これらも実行してみる、という扱いで良いと思います。

- 参考  
`error: Unable to load dependency HDF5, make sure HDF5 is installed properly`

https://stackoverflow.com/questions/66741778/how-to-install-h5py-needed-for-keras-on-macos-with-m1


# 3. エラー発生状況の詳細

## 3-1. テキストⅷページ記載の方法で失敗

テキスト（「Python ではじめるオープンエンドな進化的アルゴリズム」）に書かれている `conda env create -f environment.yml` を実行しようとしたけど、以下のようなエラーが出る。

```bash
evogym % conda env create -f environment.yml
Channels:
 - defaults
 - conda-forge
Platform: osx-arm64
Collecting package metadata (repodata.json): done
Solving environment: done

Downloading and Extracting Packages:
                                                                                                                      
Preparing transaction: done                                                                                           
Verifying transaction: done                                                                                           
Executing transaction: done                                                                                           
Installing pip dependencies: \ Ran pip subprocess with arguments:                                                   

...

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for h5py
ERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (gpy, h5py)

failed

CondaEnvException: Pip failed
```

これは `h5py` の install 失敗エラーの状況。
色々試したけどうんともすんとも言わなかったので、 conda 環境を削除しました。


```bash
# conda 環境の削除
% conda remove -n evogym --all
```

# 3-2. 各エラーに対する対処方法
以下の記事の手順に従いましたが、

https://oreilly-japan.github.io/OpenEndedCodebook/app6/

それでもいくつかエラーが出てきたので、細かい対処法を以下に記していきます。


## 3-2-1. torch

torch のインストールでエラー。

```
ERROR: Could not find a version that satisfies the requirement torch==1.10.2 (from versions: 1.11.0, 1.12.0, 1.12.1, 1.13.0, 1.13.1, 2.0.0, 2.0.1, 2.1.0, 2.1.1, 2.1.2, 2.2.0, 2.2.1, 2.2.2, 2.3.0, 2.3.1, 2.4.0, 2.4.1)
ERROR: No matching distribution found for torch==1.10.2
```

`1.10.2` などというバージョンはないらしい。1.10.2 からバージョンを上げすぎると動かなくなるかも、と思ったので、少しだけバージョンをあげて動かした。

```:requirements.txt
torch==1.12.1
```

これで行けた。

## 3-2-2. h5py

h5py のインストールでエラー。
エラー全文は長すぎるので畳んであります。

<details><summary>エラー文</summary>

```
Building wheels for collected packages: h5py
  Building wheel for h5py (pyproject.toml) ... error
  error: subprocess-exited-with-error
  
  × Building wheel for h5py (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [530 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build/lib.macosx-13.5-arm64-cpython-310/h5py
      copying h5py/h5py_warnings.py -> build/lib.macosx-13.5-arm64-cpython-310/h5py
      copying h5py/version.py -> build/lib.macosx-13.5-arm64-cpython-310/h5py
      copying h5py/__init__.py -> build/lib.macosx-13.5-arm64-cpython-310/h5py
      copying h5py/ipy_completer.py -> build/lib.macosx-13.5-arm64-cpython-310/h5py
      creating build/lib.macosx-13.5-arm64-cpython-310/h5py/_hl
      copying h5py/_hl/files.py -> build/lib.macosx-13.5-arm64-cpython-310/h5py/_hl
      copying h5py/_hl/compat.py -> build/lib.macosx-13.5-arm64-cpython-310/h5py/_hl
      copying h5py/_hl/__init__.py -> build/lib.macosx-13.5-arm64-cpython-310/h5py/_hl
      copying h5py/_hl/selections.py -> build/lib.macosx-13.5-arm64-cpython-310/h5py/_hl
      copying h5py/_hl/dataset.py -> build/lib.macosx-13.5-arm64-cpython-310/h5py/_hl
      copying h5py/_hl/vds.py -> build/lib.macosx-13.5-arm64-cpython-310/h5py/_hl
      copying h5py/_hl/selections2.py -> build/lib.macosx-13.5-arm64-cpython-310/h5py/_hl
      copying h5py/_hl/group.py -> build/lib.macosx-13.5-arm64-cpython-310/h5py/_hl
      copying h5py/_hl/datatype.py -> build/lib.macosx-13.5-arm64-cpython-310/h5py/_hl
      copying h5py/_hl/attrs.py -> build/lib.macosx-13.5-arm64-cpython-310/h5py/_hl
      copying h5py/_hl/dims.py -> build/lib.macosx-13.5-arm64-cpython-310/h5py/_hl
      copying h5py/_hl/base.py -> build/lib.macosx-13.5-arm64-cpython-310/h5py/_hl
      copying h5py/_hl/filters.py -> build/lib.macosx-13.5-arm64-cpython-310/h5py/_hl
      creating build/lib.macosx-13.5-arm64-cpython-310/h5py/tests
      copying h5py/tests/test_dimension_scales.py -> build/lib.macosx-13.5-arm64-cpython-310/h5py/tests
      copying h5py/tests/test_attribute_create.py -> build/lib.macosx-13.5-arm64-cpython-310/h5py/tests
      copying h5py/tests/test_file_image.py -> build/lib.macosx-13.5-arm64-cpython-310/h5py/tests
      copying h5py/tests/conftest.py -> build/lib.macosx-13.5-arm64-cpython-310/h5py/tests
      copying h5py/tests/test_h5d_direct_chunk.py -> build/lib.macosx-13.5-arm64-cpython-310/h5py/tests
      copying h5py/tests/test_h5f.py -> build/lib.macosx-13.5-arm64-cpython-310/h5py/tests
      copying h5py/tests/test_dataset_getitem.py -> build/lib.macosx-13.5-arm64-cpython-310/h5py/tests
      copying h5py/tests/test_group.py -> build/lib.macosx-13.5-arm64-cpython-310/h5py/tests
      copying h5py/tests/test_errors.py -> build/lib.macosx-13.5-arm64-cpython-310/h5py/tests
      copying h5py/tests/test_dataset_swmr.py -> build/lib.macosx-13.5-arm64-cpython-310/h5py/tests
      copying h5py/tests/test_slicing.py -> build/lib.macosx-13.5-arm64-cpython-310/h5py/tests
      copying h5py/tests/test_h5pl.py -> build/lib.macosx-13.5-arm64-cpython-310/h5py/tests
      copying h5py/tests/test_attrs.py -> build/lib.macosx-13.5-arm64-cpython-310/h5py/tests
      copying h5py/tests/__init__.py -> build/lib.macosx-13.5-arm64-cpython-310/h5py/tests
      copying h5py/tests/test_attrs_data.py -> build/lib.macosx-13.5-arm64-cpython-310/h5py/tests
      copying h5py/tests/test_h5t.py -> build/lib.macosx-13.5-arm64-cpython-310/h5py/tests
      copying h5py/tests/test_big_endian_file.py -> build/lib.macosx-13.5-arm64-cpython-310/h5py/tests
      copying h5py/tests/test_h5p.py -> build/lib.macosx-13.5-arm64-cpython-310/h5py/tests
      copying h5py/tests/test_dims_dimensionproxy.py -> build/lib.macosx-13.5-arm64-cpython-310/h5py/tests
      copying h5py/tests/test_h5o.py -> build/lib.macosx-13.5-arm64-cpython-310/h5py/tests
      copying h5py/tests/test_datatype.py -> build/lib.macosx-13.5-arm64-cpython-310/h5py/tests
      copying h5py/tests/common.py -> build/lib.macosx-13.5-arm64-cpython-310/h5py/tests
      copying h5py/tests/test_dataset.py -> build/lib.macosx-13.5-arm64-cpython-310/h5py/tests
      copying h5py/tests/test_file.py -> build/lib.macosx-13.5-arm64-cpython-310/h5py/tests
      copying h5py/tests/test_selections.py -> build/lib.macosx-13.5-arm64-cpython-310/h5py/tests
      copying h5py/tests/test_dtype.py -> build/lib.macosx-13.5-arm64-cpython-310/h5py/tests
      copying h5py/tests/test_h5.py -> build/lib.macosx-13.5-arm64-cpython-310/h5py/tests
      copying h5py/tests/test_file2.py -> build/lib.macosx-13.5-arm64-cpython-310/h5py/tests
      copying h5py/tests/test_completions.py -> build/lib.macosx-13.5-arm64-cpython-310/h5py/tests
      copying h5py/tests/test_filters.py -> build/lib.macosx-13.5-arm64-cpython-310/h5py/tests
      copying h5py/tests/test_base.py -> build/lib.macosx-13.5-arm64-cpython-310/h5py/tests
      copying h5py/tests/test_objects.py -> build/lib.macosx-13.5-arm64-cpython-310/h5py/tests
      creating build/lib.macosx-13.5-arm64-cpython-310/h5py/tests/data_files
      copying h5py/tests/data_files/__init__.py -> build/lib.macosx-13.5-arm64-cpython-310/h5py/tests/data_files
      creating build/lib.macosx-13.5-arm64-cpython-310/h5py/tests/test_vds
      copying h5py/tests/test_vds/test_highlevel_vds.py -> build/lib.macosx-13.5-arm64-cpython-310/h5py/tests/test_vds
      copying h5py/tests/test_vds/test_virtual_source.py -> build/lib.macosx-13.5-arm64-cpython-310/h5py/tests/test_vds
      copying h5py/tests/test_vds/__init__.py -> build/lib.macosx-13.5-arm64-cpython-310/h5py/tests/test_vds
      copying h5py/tests/test_vds/test_lowlevel_vds.py -> build/lib.macosx-13.5-arm64-cpython-310/h5py/tests/test_vds
      copying h5py/tests/data_files/vlen_string_s390x.h5 -> build/lib.macosx-13.5-arm64-cpython-310/h5py/tests/data_files
      copying h5py/tests/data_files/vlen_string_dset_utc.h5 -> build/lib.macosx-13.5-arm64-cpython-310/h5py/tests/data_files
      copying h5py/tests/data_files/vlen_string_dset.h5 -> build/lib.macosx-13.5-arm64-cpython-310/h5py/tests/data_files
      running build_ext
      warning: h5py/defs.pxd:15:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/defs.pxd:62:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/defs.pxd:64:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/defs.pxd:66:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/defs.pxd:68:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/defs.pxd:70:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/defs.pxd:72:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/defs.pxd:74:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/defs.pxd:76:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/defs.pxd:78:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/defs.pxd:102:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/defs.pxd:104:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/defs.pxd:106:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/defs.pxd:107:4: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/defs.pxd:109:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/defs.pxd:110:4: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/defs.pxd:112:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/defs.pxd:114:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/defs.pxd:116:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/defs.pxd:180:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/defs.pxd:197:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/defs.pxd:199:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/defs.pxd:201:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/defs.pxd:203:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/defs.pxd:213:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/defs.pxd:215:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/defs.pxd:229:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/defs.pxd:231:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/defs.pxd:233:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/defs.pxd:235:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/defs.pxd:237:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/defs.pxd:239:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/defs.pxd:241:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/defs.pxd:269:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/defs.pxd:271:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/defs.pxd:273:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/defs.pxd:275:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/defs.pxd:277:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/defs.pxd:279:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/defs.pxd:285:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/defs.pxd:287:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/defs.pxd:289:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/defs.pxd:291:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/defs.pxd:293:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/defs.pxd:295:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/defs.pxd:297:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/defs.pxd:299:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/defs.pxd:333:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/defs.pxd:335:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/defs.pxd:337:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/defs.pxd:339:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/defs.pxd:341:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/defs.pxd:343:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/defs.pxd:345:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/defs.pxd:347:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/defs.pxd:349:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/defs.pxd:383:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/defs.pxd:385:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/api_types_hdf5.pxd:48:2: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/api_types_hdf5.pxd:64:2: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/api_types_hdf5.pxd:143:2: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/api_types_hdf5.pxd:148:2: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/api_types_hdf5.pxd:156:2: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/api_types_hdf5.pxd:165:2: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/api_types_hdf5.pxd:198:2: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/api_types_hdf5.pxd:287:2: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/api_types_hdf5.pxd:334:2: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/api_types_ext.pxd:14:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/api_types_ext.pxd:25:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/api_types_ext.pxd:52:4: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/_conv.pyx:161:8: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/_conv.pyx:422:8: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      warning: h5py/h5r.pxd:17:0: The 'IF' statement is deprecated and will be removed in a future Cython version. Consider using runtime conditions or C macros instead. See https://github.com/cython/cython/issues/4310
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
      # License:  Standard 3-clause BSD; see "license.txt" for full license terms
      #           and contributor agreement.
      
      from .defs cimport *
      
      from ._objects cimport class ObjectID
                             ^
      ------------------------------------------------------------
      
      h5py/h5t.pxd:13:23: Expected an identifier
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
      
      from logging import getLogger
      
      from .h5 import get_config
      from .h5r cimport Reference, RegionReference, hobj_ref_t, hdset_reg_ref_t
      from .h5t cimport H5PY_OBJ, typewrap, py_create, TypeID, H5PY_PYTHON_OPAQUE_TAG
      ^
      ------------------------------------------------------------
      
      h5py/_conv.pyx:21:0: 'h5py/h5t/H5PY_OBJ.pxd' not found
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
      
      from logging import getLogger
      
      from .h5 import get_config
      from .h5r cimport Reference, RegionReference, hobj_ref_t, hdset_reg_ref_t
      from .h5t cimport H5PY_OBJ, typewrap, py_create, TypeID, H5PY_PYTHON_OPAQUE_TAG
      ^
      ------------------------------------------------------------
      
      h5py/_conv.pyx:21:0: 'h5py/h5t/typewrap.pxd' not found
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
      
      from logging import getLogger
      
      from .h5 import get_config
      from .h5r cimport Reference, RegionReference, hobj_ref_t, hdset_reg_ref_t
      from .h5t cimport H5PY_OBJ, typewrap, py_create, TypeID, H5PY_PYTHON_OPAQUE_TAG
      ^
      ------------------------------------------------------------
      
      h5py/_conv.pyx:21:0: 'h5py/h5t/py_create.pxd' not found
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
      
      from logging import getLogger
      
      from .h5 import get_config
      from .h5r cimport Reference, RegionReference, hobj_ref_t, hdset_reg_ref_t
      from .h5t cimport H5PY_OBJ, typewrap, py_create, TypeID, H5PY_PYTHON_OPAQUE_TAG
      ^
      ------------------------------------------------------------
      
      h5py/_conv.pyx:21:0: 'h5py/h5t/TypeID.pxd' not found
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
      
      from logging import getLogger
      
      from .h5 import get_config
      from .h5r cimport Reference, RegionReference, hobj_ref_t, hdset_reg_ref_t
      from .h5t cimport H5PY_OBJ, typewrap, py_create, TypeID, H5PY_PYTHON_OPAQUE_TAG
      ^
      ------------------------------------------------------------
      
      h5py/_conv.pyx:21:0: 'h5py/h5t/H5PY_PYTHON_OPAQUE_TAG.pxd' not found
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
          void* ptr
      
      cdef int conv_vlen2ndarray(void* ipt,
                                 void* opt,
                                 cnp.dtype elem_dtype,
                                 TypeID intype,
                                 ^
      ------------------------------------------------------------
      
      h5py/_conv.pyx:687:27: 'TypeID' is not a type identifier
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
      
      cdef int conv_vlen2ndarray(void* ipt,
                                 void* opt,
                                 cnp.dtype elem_dtype,
                                 TypeID intype,
                                 TypeID outtype) except -1:
                                 ^
      ------------------------------------------------------------
      
      h5py/_conv.pyx:688:27: 'TypeID' is not a type identifier
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
          return 0
      
      
      cdef int conv_ndarray2vlen(void* ipt,
                                 void* opt,
                                 TypeID intype,
                                 ^
      ------------------------------------------------------------
      
      h5py/_conv.pyx:820:27: 'TypeID' is not a type identifier
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
      
      
      cdef int conv_ndarray2vlen(void* ipt,
                                 void* opt,
                                 TypeID intype,
                                 TypeID outtype) except -1:
                                 ^
      ------------------------------------------------------------
      
      h5py/_conv.pyx:821:27: 'TypeID' is not a type identifier
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
          :return: error-code
          """
          cdef:
              int command = cdata[0].command
              size_t src_size, dst_size
              TypeID supertype
              ^
      ------------------------------------------------------------
      
      h5py/_conv.pyx:629:8: 'TypeID' is not a type identifier
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
          """
          cdef:
              int command = cdata[0].command
              size_t src_size, dst_size
              TypeID supertype
              TypeID outtype
              ^
      ------------------------------------------------------------
      
      h5py/_conv.pyx:630:8: 'TypeID' is not a type identifier
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
                               void *bkg_i,
                               hid_t dxpl) except -1 with gil:
          cdef:
              int command = cdata[0].command
              size_t src_size, dst_size
              TypeID supertype
              ^
      ------------------------------------------------------------
      
      h5py/_conv.pyx:752:8: 'TypeID' is not a type identifier
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
                               hid_t dxpl) except -1 with gil:
          cdef:
              int command = cdata[0].command
              size_t src_size, dst_size
              TypeID supertype
              TypeID outtype
              ^
      ------------------------------------------------------------
      
      h5py/_conv.pyx:753:8: 'TypeID' is not a type identifier
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
          cdef char* ctag = NULL
          try:
              if H5Tget_class(obj) == H5T_OPAQUE:
                  ctag = H5Tget_tag(obj)
                  if ctag != NULL:
                      if strcmp(ctag, H5PY_PYTHON_OPAQUE_TAG) == 0:
                                      ^
      ------------------------------------------------------------
      
      h5py/_conv.pyx:157:32: 'H5PY_PYTHON_OPAQUE_TAG' is not a constant, variable or function identifier
      warning: h5py/_conv.pyx:157:32: Obtaining 'const char *' from externally modifiable global Python value
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
          elif command == H5T_CONV_FREE:
              pass
      
          elif command == H5T_CONV_CONV:
              # need to pass element dtype to converter
              supertype = typewrap(H5Tget_super(src_id))
                          ^
      ------------------------------------------------------------
      
      h5py/_conv.pyx:645:20: 'typewrap' is not a constant, variable or function identifier
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
      
          elif command == H5T_CONV_CONV:
              # need to pass element dtype to converter
              supertype = typewrap(H5Tget_super(src_id))
              dt = supertype.dtype
              outtype = py_create(dt)
                        ^
      ------------------------------------------------------------
      
      h5py/_conv.pyx:647:18: 'py_create' is not a constant, variable or function identifier
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
              PyObject *pdata_elem
              char* buf = <char*>buf_i
      
          if command == H5T_CONV_INIT:
              cdata[0].need_bkg = H5T_BKG_NO
              if not H5Tequal(src_id, H5PY_OBJ) or H5Tget_class(dst_id) != H5T_VLEN:
                                      ^
      ------------------------------------------------------------
      
      h5py/_conv.pyx:761:32: 'H5PY_OBJ' is not a constant, variable or function identifier
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
      
          if command == H5T_CONV_INIT:
              cdata[0].need_bkg = H5T_BKG_NO
              if not H5Tequal(src_id, H5PY_OBJ) or H5Tget_class(dst_id) != H5T_VLEN:
                  return -2
              supertype = typewrap(H5Tget_super(dst_id))
                          ^
      ------------------------------------------------------------
      
      h5py/_conv.pyx:763:20: 'typewrap' is not a constant, variable or function identifier
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
                  return -2
              supertype = typewrap(H5Tget_super(dst_id))
              for i in range(nl):
                  # smells a lot
                  memcpy(&pdata_elem, pdata+i, sizeof(pdata_elem))
                  if supertype != py_create((<cnp.ndarray> pdata_elem).dtype, 1):
                                  ^
      ------------------------------------------------------------
      
      h5py/_conv.pyx:767:28: 'py_create' is not a constant, variable or function identifier
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
              if nl == 0:
                  return 0
      
              # need to pass element dtype to converter
              pdata_elem = pdata[0]
              supertype = py_create((<cnp.ndarray> pdata_elem).dtype)
                          ^
      ------------------------------------------------------------
      
      h5py/_conv.pyx:784:20: 'py_create' is not a constant, variable or function identifier
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
                  return 0
      
              # need to pass element dtype to converter
              pdata_elem = pdata[0]
              supertype = py_create((<cnp.ndarray> pdata_elem).dtype)
              outtype = typewrap(H5Tget_super(dst_id))
                        ^
      ------------------------------------------------------------
      
      h5py/_conv.pyx:785:18: 'typewrap' is not a constant, variable or function identifier
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
      
          enum = H5Tenum_create(H5T_STD_I32LE)
      
          vlentype = H5Tvlen_create(H5T_STD_I32LE)
      
          pyobj = H5PY_OBJ
                  ^
      ------------------------------------------------------------
      
      h5py/_conv.pyx:894:12: 'H5PY_OBJ' is not a constant, variable or function identifier
      Loading library to get build settings and version: /opt/homebrew/Cellar/hdf5/1.14.3_1/lib/libhdf5.dylib
      ********************************************************************************
                             Summary of the h5py configuration
      
      HDF5 include dirs: [
        '/opt/homebrew/Cellar/hdf5/1.14.3_1/include'
      ]
      HDF5 library dirs: [
        '/opt/homebrew/Cellar/hdf5/1.14.3_1/lib'
      ]
           HDF5 Version: (1, 14, 3)
            MPI Enabled: False
       ROS3 VFD Enabled: False
       Rebuild Required: True
      
      ********************************************************************************
      Executing api_gen rebuild of defs
      Executing cythonize()
      [ 1/24] Cythonizing /private/var/folders/7r/d08538nj63ncgxpk9jwhpxsc0000gp/T/pip-install-71dv4mke/h5py_fda1489589c54f57b0ddefc02e45f9d9/h5py/_conv.pyx
      Traceback (most recent call last):
        File "/Users/username/src/evogym/env-evogym/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/Users/username/src/evogym/env-evogym/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/Users/username/src/evogym/env-evogym/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 251, in build_wheel
          return _build_backend().build_wheel(wheel_directory, config_settings,
        File "/private/var/folders/7r/d08538nj63ncgxpk9jwhpxsc0000gp/T/pip-build-env-dbh4er50/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 421, in build_wheel
          return self._build_with_temp_dir(
        File "/private/var/folders/7r/d08538nj63ncgxpk9jwhpxsc0000gp/T/pip-build-env-dbh4er50/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 403, in _build_with_temp_dir
          self.run_setup()
        File "/private/var/folders/7r/d08538nj63ncgxpk9jwhpxsc0000gp/T/pip-build-env-dbh4er50/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 318, in run_setup
          exec(code, locals())
        File "<string>", line 104, in <module>
        File "/private/var/folders/7r/d08538nj63ncgxpk9jwhpxsc0000gp/T/pip-build-env-dbh4er50/overlay/lib/python3.10/site-packages/setuptools/__init__.py", line 117, in setup
          return distutils.core.setup(**attrs)
        File "/private/var/folders/7r/d08538nj63ncgxpk9jwhpxsc0000gp/T/pip-build-env-dbh4er50/overlay/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 183, in setup
          return run_commands(dist)
        File "/private/var/folders/7r/d08538nj63ncgxpk9jwhpxsc0000gp/T/pip-build-env-dbh4er50/overlay/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 199, in run_commands
          dist.run_commands()
        File "/private/var/folders/7r/d08538nj63ncgxpk9jwhpxsc0000gp/T/pip-build-env-dbh4er50/overlay/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 954, in run_commands
          self.run_command(cmd)
        File "/private/var/folders/7r/d08538nj63ncgxpk9jwhpxsc0000gp/T/pip-build-env-dbh4er50/overlay/lib/python3.10/site-packages/setuptools/dist.py", line 950, in run_command
          super().run_command(command)
        File "/private/var/folders/7r/d08538nj63ncgxpk9jwhpxsc0000gp/T/pip-build-env-dbh4er50/overlay/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 973, in run_command
          cmd_obj.run()
        File "/private/var/folders/7r/d08538nj63ncgxpk9jwhpxsc0000gp/T/pip-build-env-dbh4er50/overlay/lib/python3.10/site-packages/setuptools/command/bdist_wheel.py", line 398, in run
          self.run_command("build")
        File "/private/var/folders/7r/d08538nj63ncgxpk9jwhpxsc0000gp/T/pip-build-env-dbh4er50/overlay/lib/python3.10/site-packages/setuptools/_distutils/cmd.py", line 316, in run_command
          self.distribution.run_command(command)
        File "/private/var/folders/7r/d08538nj63ncgxpk9jwhpxsc0000gp/T/pip-build-env-dbh4er50/overlay/lib/python3.10/site-packages/setuptools/dist.py", line 950, in run_command
          super().run_command(command)
        File "/private/var/folders/7r/d08538nj63ncgxpk9jwhpxsc0000gp/T/pip-build-env-dbh4er50/overlay/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 973, in run_command
          cmd_obj.run()
        File "/private/var/folders/7r/d08538nj63ncgxpk9jwhpxsc0000gp/T/pip-build-env-dbh4er50/overlay/lib/python3.10/site-packages/setuptools/_distutils/command/build.py", line 135, in run
          self.run_command(cmd_name)
        File "/private/var/folders/7r/d08538nj63ncgxpk9jwhpxsc0000gp/T/pip-build-env-dbh4er50/overlay/lib/python3.10/site-packages/setuptools/_distutils/cmd.py", line 316, in run_command
          self.distribution.run_command(command)
        File "/private/var/folders/7r/d08538nj63ncgxpk9jwhpxsc0000gp/T/pip-build-env-dbh4er50/overlay/lib/python3.10/site-packages/setuptools/dist.py", line 950, in run_command
          super().run_command(command)
        File "/private/var/folders/7r/d08538nj63ncgxpk9jwhpxsc0000gp/T/pip-build-env-dbh4er50/overlay/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 973, in run_command
          cmd_obj.run()
        File "/private/var/folders/7r/d08538nj63ncgxpk9jwhpxsc0000gp/T/pip-install-71dv4mke/h5py_fda1489589c54f57b0ddefc02e45f9d9/setup_build.py", line 170, in run
          self.extensions = cythonize(self._make_extensions(config),
        File "/private/var/folders/7r/d08538nj63ncgxpk9jwhpxsc0000gp/T/pip-build-env-dbh4er50/overlay/lib/python3.10/site-packages/Cython/Build/Dependencies.py", line 1154, in cythonize
          cythonize_one(*args)
        File "/private/var/folders/7r/d08538nj63ncgxpk9jwhpxsc0000gp/T/pip-build-env-dbh4er50/overlay/lib/python3.10/site-packages/Cython/Build/Dependencies.py", line 1321, in cythonize_one
          raise CompileError(None, pyx_file)
      Cython.Compiler.Errors.CompileError: /private/var/folders/7r/d08538nj63ncgxpk9jwhpxsc0000gp/T/pip-install-71dv4mke/h5py_fda1489589c54f57b0ddefc02e45f9d9/h5py/_conv.pyx
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for h5py
Failed to build h5py
ERROR: Could not build wheels for h5py, which is required to install pyproject.toml-based projects
```
</details>

以下の記事の解決策に従う。

https://blog.symdon.info/posts/1697859818/

https://oreilly-japan.github.io/OpenEndedCodebook/app6/

2つ目の記事の「h5pyのインストールに失敗する」の項によると、「Cython==3.0.4」なら動くらしいので、これを入れておく。

```:requirements.txt
Cython==3.0.4
h5py==3.10.0
```

これでインストールできたよ。

## 3-2-3. PyOpenGL-accelerate

`PyOpenGL-accelerate` のインストールでエラー。

試しに、直接 pip install してみても、

```
% pip install PyOpenGL-accelerate
```

エラーが発生し、中でも以下の部分が原因のように見えて気になったので調べてみると、

```bash
src/numpy_formathandler.pyx:22:42: 'Py_intptr_t' is not a type identifier
```

以下の issue で解決策が示されていた。

https://github.com/mcfletch/pyopengl/issues/118#issuecomment-2351365603

直接 GitHub リポジトリから pip install する手順を stackoverflow で調べて...

https://stackoverflow.com/questions/23521345/python-pip-how-do-i-install-a-specific-version-of-a-git-repository-from-githu

以下のように修正。

```:requirements.txt
# PyOpenGL==3.1.5
# PyOpenGL-accelerate==3.1.5
PyOpenGL @ git+https://github.com/mcfletch/pyopengl.git@release-3.1.8#egg=PyOpenGL
PyOpenGL_accelerate @ git+https://github.com/mcfletch/pyopengl.git@release-3.1.8#egg=PyOpenGL_accelerate&subdirectory=accelerate
```

再度 pip install したらうまくいった。


# 4. 最終 requirements.txt

[`OpenEndedCodebook`](https://github.com/oreilly-japan/OpenEndedCodebook) の方の pip install も終えた後に確認したところ、以下のモジュールがインストールされた状態になっていました。

```bash
$ pip freeze
cloudpickle==3.0.0
cycler==0.12.1
Cython==3.0.4
decorator==5.1.1
# evogym のインストール先は、マシンによって違うと思います
# evogym @ file:///Users/username/src/evogym
fonttools==4.54.1
glfw==2.5.0
GPy==1.10.0
GPyOpt==1.2.6
gym==0.22.0
gym-notices==0.0.8
h5py==3.10.0
imageio==2.14.1
kiwisolver==1.4.7
matplotlib==3.5.1
neat-python==0.92
networkx==2.8.2
numpy==1.21.5
opencv-python==4.5.5.62
packaging==24.1
pandas==2.0.3
paramz==0.9.6
Pillow==9.0.0
pybind11==2.9.0
pygifsicle==1.0.5
PyOpenGL @ git+https://github.com/mcfletch/pyopengl.git@41105583e27264f8e01fb0b711ca8e44ac444f56
PyOpenGL-accelerate @ git+https://github.com/mcfletch/pyopengl.git@41105583e27264f8e01fb0b711ca8e44ac444f56#subdirectory=accelerate
pyparsing==3.1.4
python-dateutil==2.9.0.post0
pytz==2024.2
scipy==1.10.1
six==1.16.0
torch==1.12.1
ttkbootstrap==1.5.1
typing==3.7.4.3
typing_extensions==4.12.2
tzdata==2024.2
```

お役に立てますと幸いです^^


# おまけ

一度 pip install に成功しても、PC消して再度作業しようとした時、やり方がわからなくなったりしますよね。
その時は、以下の記事の頭の方に仮想環境の起動方法が書いてあるので、参考にして下さいね^^

https://oreilly-japan.github.io/OpenEndedCodebook/app6/

それでは、良いコーディングを(\*˘︶˘\*).｡.:\*