LoginSignup
2
2

More than 1 year has passed since last update.

MacOS Big Sur でPyxelをインストールしたらハマった件のまとめ

Posted at

Pythonでゲーム作り

ひょんなことからPythonでゲームを作ることになり、色々と探しているとPyxel という良さげなライブラリを見つけたので、使って見ることにしました。
しかし、インストールでハマったので、健忘録を残します。

まずはリファレンス通りにインストール

Pyxel のリファレンスを参考にインストールを進めます。
そのまま動く人は、それでOKです。
ただし、

$ install_pyxel_examples

と入力して

Traceback (most recent call last):
  File "/usr/local/bin/install_pyxel_examples", line 5, in <module>
    from pyxel.examples import install
  File "/usr/local/lib/python3.9/site-packages/pyxel/__init__.py", line 10, in <module>
    from . import core  # type: ignore
  File "/usr/local/lib/python3.9/site-packages/pyxel/core/__init__.py", line 42, in <module>
    _lib = _load_library()
  File "/usr/local/lib/python3.9/site-packages/pyxel/core/__init__.py", line 39, in _load_library
    return cdll.LoadLibrary(lib_path)
  File "/usr/local/Cellar/python@3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/ctypes/__init__.py", line 452, in LoadLibrary
    return self._dlltype(name)
  File "/usr/local/Cellar/python@3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/ctypes/__init__.py", line 374, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: dlopen(/usr/local/lib/python3.9/site-packages/pyxel/core/bin/macos/libpyxelcore.dylib, 6): Symbol not found: __ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE16find_last_not_ofEPKcmm
  Referenced from: /usr/local/lib/python3.9/site-packages/pyxel/core/bin/macos/libpyxelcore.dylib
  Expected in: /usr/lib/libstdc++.6.dylib
 in /usr/local/lib/python3.9/site-packages/pyxel/core/bin/macos/libpyxelcore.dylib

のエラーコードが出る場合は

$ pip3 install -U pyxel

インストールの有無を一度確認し、

Requirement already satisfied: pyxel in /usr/local/lib/python3.9/site-packages (1.4.3)

すでにインストール済みと表示されるので、

$ pip3 uninstall pyxel   

一度アンインストールし、

Found existing installation: pyxel 1.4.3
Uninstalling pyxel-1.4.3:
  Would remove:
    /usr/local/bin/install_pyxel_examples
    /usr/local/bin/pyxeleditor
    /usr/local/bin/pyxelpackager
    /usr/local/lib/python3.9/site-packages/pyxel-1.4.3.dist-info/*
    /usr/local/lib/python3.9/site-packages/pyxel/*
Proceed (y/n)? y
  Successfully uninstalled pyxel-1.4.3

再度、no-binary バージョンでインストールを試みます。

$ pip3 install --no-binary :all: pyxel

その後は、

$ install_pyxel_examples
$ cd pyxel_examples
$ python3 01_hello_pyxel.py

無事に動きました!

参考サイト

https://github.com/kitao/pyxel/issues/302
https://teratail.com/questions/341644

2
2
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2