LoginSignup
0
0

More than 1 year has passed since last update.

import rayでSymbol not found: _Py_GetArgc_Argvが出たときの対処法メモ

Posted at

こちらの記事を読み、なるほどこれはよさそうだとpip installしてimport rayしたところ表題のエラーが出たのでその対処法のメモです。

エラー発生時の環境

macOS Big Sur 11.3.1
Python 3.8.2
ray 1.4.0

事象

rayをインストールしました。

pip install ray

Pythonコード内でインポートしました。

import ray

ここでエラーが発生しました。(ファイル名や一部のパスは伏せてあります。)

Traceback (most recent call last):
  File "~~~~.py", line 6, in <module>
    import ray
  File "~~~~/.venv/lib/python3.8/site-packages/ray/__init__.py", line 42, in <module>
    import ray._raylet  # noqa: E402
  File "python/ray/_raylet.pyx", line 87, in init ray._raylet
  File "~~~~/.venv/lib/python3.8/site-packages/ray/exceptions.py", line 6, in <module>
    import setproctitle
ImportError: dlopen(~~~~/.venv/lib/python3.8/site-packages/ray/thirdparty_files/setproctitle.cpython-38-darwin.so, 2): Symbol not found: _Py_GetArgcArgv
  Referenced from: ~~~~/.venv/lib/python3.8/site-packages/ray/thirdparty_files/setproctitle.cpython-38-darwin.so
  Expected in: flat namespace
 in ~~~~/.venv/lib/python3.8/site-packages/ray/thirdparty_files/setproctitle.cpython-38-darwin.so

対処法

1. Pythonのバージョンを変更

同様のエラーが以下のIssueに挙がっていたので、それを参考にPythonのバージョンを変更(3.8.2 -> 3.8.5)することにしました。

自分はvenvで作成した仮想環境を使用していたので、以下の記事を参考にPythonのバージョンを変更しました。

pyenvによるPythonバージョンの変更は以下の記事もご参照ください。

2. pip install 'ray[default]'

さて、改めてpip install rayでインストールし、import rayを含むPythonファイルを実行すると、エラーは出ませんでしたが以下のようなFutureWarningが出ました。

~~~~/.venv/lib/python3.8/site-packages/ray/autoscaler/_private/cli_logger.py:57: FutureWarning: Not all Ray CLI dependencies were found. In Ray 1.4+, the Ray CLI, autoscaler, and dashboard will only be usable via `pip install 'ray[default]'`. Please update your install command.
  warnings.warn(

指示通りに以下のコマンドでインストールし直すと、FutureWarningも出なくなりました。

pip install 'ray[default]'

以上です。

0
0
0

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
0
0