LoginSignup
4
0

More than 5 years have passed since last update.

[Flutter] デバッグ時にPythonのImportErrorが起きた話

Last updated at Posted at 2018-05-19

出くわしたエラー

状況

VSCodeからDebugをStartしてアプリを起動した際、以下のエラーが出た。
なお、アプリの起動・挙動には問題なし。

エラー内容

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/usr/local/Cellar/python@2/2.7.15/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 52, in <module>
    import weakref
  File "/usr/local/Cellar/python@2/2.7.15/Frameworks/Python.framework/Versions/2.7/lib/python2.7/weakref.py", line 14, in <module>
    from _weakref import (
ImportError: cannot import name _remove_dead_weakref

原因

そもそもこれはpythonのエラーであり、flutterのエラーではない。

なぜ発生したか。
flutterのインストール後にflutter doctorを叩き、
✗ Missing Xcode dependency: Python module "six".」というメッセージが出たので、
brewでpythonをダウンロードしたのだが、それが原因だったぽい。(たぶん競合)

解決策

brew remove python@2 --ignore-dependencies
でいけた。

念のため、flutter doctorを叩いて問題がないことを確認する。

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, v0.3.2, on Mac OS X 10.13.4 17E202, locale ja-JP)
[✓] Android toolchain - develop for Android devices (Android SDK 27.0.3)
[✓] iOS toolchain - develop for iOS devices (Xcode 9.3.1)
[✓] Android Studio (version 3.1)
[✓] VS Code (version 1.22.2)
[✓] Connected devices (1 available)

• No issues found!
4
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
4
0