1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

pyenv + virtualenv + mmcvのインストールエラー

Posted at

はじめに

Pyenv+Virtualenvで環境構築をしていて、mmcv-fullをインストールしようとしたらエラーが出た人向け。

現象

インストールすると、cmath系のエラーがたくさん出る。

$ pip install mmcv-full
......<省略>
de/ATen/core/aten_interned_strings.h:633:9: note: expanded from macro 'FORALL_ATEN_BASE_SYMBOLS'
      _(aten, signbit) \
              ^
      fatal error: too many errors emitted, stopping now [-ferror-limit=]
      20 errors generated.
      error: command 'clang' failed with exit status 1
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> mmcv-full

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.

対策

SDKの参照先関係の理由が考えられるので、対策1,対策2を行った上で、Pyenvの環境を再構築する。
PyenvでPyenv installしたあとに、CommandLineToolを変更した場合などに、SDK参照先のコンフリクトが起きて発生しそう。正直詳細はわかっていないけど、下記手順で回復できた。詳しい人教えてください。

対策1: xcode-selectの再インストール

sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install

対策2: SDKの参照先を確認

こんなふうに表示されれば問題ない。

$ xcrun --show-sdk-path
/Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk

ちなみに、参照先を変更したい場合は、下記の様なコマンドを打つ。

$ sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
$ xcrun --show-sdk-path
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk

参照先をデフォルトに戻したい場合は、下記で戻せる。

$ sudo xcode-select --reset

Pyenv virtualenvでの環境再構築

これは普通に削除して、再インストールする。

$ pyenv virtualenv-delete <ENV_NAME>
$ pyenv uninstall <BASE PYTHON VER>
$ pyenv install <BASE PYTHON VER>
$ pyenv virtualenv <BASE PYTHON VER> <ENV_NAME>

結果

$ pip install mmcv-full
Collecting mmcv-full
  Using cached mmcv-full-1.4.4.tar.gz (420 kB)
Requirement already satisfied: addict in ./.pyenv/versions/3.8.12/envs/py38-mmdetection/lib/python3.8/site-packages (from mmcv-full) (2.4.0)
Requirement already satisfied: numpy in ./.pyenv/versions/3.8.12/envs/py38-mmdetection/lib/python3.8/site-packages (from mmcv-full) (1.22.2)
Requirement already satisfied: packaging in ./.pyenv/versions/3.8.12/envs/py38-mmdetection/lib/python3.8/site-packages (from mmcv-full) (21.3)
Requirement already satisfied: Pillow in ./.pyenv/versions/3.8.12/envs/py38-mmdetection/lib/python3.8/site-packages (from mmcv-full) (9.0.1)
Requirement already satisfied: pyyaml in ./.pyenv/versions/3.8.12/envs/py38-mmdetection/lib/python3.8/site-packages (from mmcv-full) (6.0)
Requirement already satisfied: yapf in ./.pyenv/versions/3.8.12/envs/py38-mmdetection/lib/python3.8/site-packages (from mmcv-full) (0.32.0)
Requirement already satisfied: pyparsing!=3.0.5,>=2.0.2 in ./.pyenv/versions/3.8.12/envs/py38-mmdetection/lib/python3.8/site-packages (from packaging->mmcv-full) (3.0.7)
Using legacy 'setup.py install' for mmcv-full, since package 'wheel' is not installed.
Installing collected packages: mmcv-full
    Running setup.py install for mmcv-full ... done
Successfully installed mmcv-full-1.4.4

無事にインストールできました。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?