I'm getting an error whenever I try to start swift related to python. How do I fix this?
bash-3.2$ swift --version
Apple Swift version 4.1 (swiftlang-902.0.48 clang-902.0.37.1)
Target: x86_64-apple-darwin17.5.0
bash-3.2$ swift
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/Cellar/python@2/2.7.14_3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 52, in
import weakref
File "/usr/local/Cellar/python@2/2.7.14_3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/weakref.py", line 14, in
from _weakref import (
ImportError: cannot import name _remove_dead_weakref
I get the same error, because the swift REPL uses the python interpreter which homebrew installed at /usr/local/bin/python
.
To avoid this you can
export PATH=/usr/bin:$PATH
swift
or
PATH=/usr/bin:$PATH swift
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With