Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

swift throws python errors from terminal

Tags:

swift

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

like image 559
Gargoyle Avatar asked Apr 28 '18 22:04

Gargoyle


1 Answers

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
like image 73
choas Avatar answered Nov 28 '22 05:11

choas