HenryRootTwo
HenryRootTwo

Reputation: 2612

Error when trying to run Swift from terminal

After entering

~   sudo xcode-select -switch /Applications/Xcode6-Beta3.app/Contents/Developer

and then

~   xcrun swift

I get an error

ImportError: No module named site
Assertion failed: (err == 0), function ~Mutex, file /SourceCache/lldb/lldb-320.4.106.2/source/Host/common/Mutex.cpp, line 246.
Abort trap: 6

What am I missing? Several tutorials online give this code, so I'm guessing it must be some sort of setup issue.

Upvotes: 0

Views: 929

Answers (2)

Tim D
Tim D

Reputation: 1743

I had a similar error and resolved it by removing the entry to my 3rd-party Python distribution (Enthought Canopy, in my case) from the PATH environment variable. This was a manual hack in my Terminal session and is good for only that session but it was as simple as this:

~ [1]$  swift
ImportError: No module named site
~ [2]$  echo $PATH
/Users/tdiller/Library/Enthought/Canopy_64bit/User/bin:/usr/local/git/bin:~/bin:/Library/Frameworks/Python.framework/Versions/Current/bin:/opt/local/bin:/opt/local/sbin:/usr/local/texlive/2012/bin/universal-darwin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/git/bin:/usr/local/go/bin
~ [3]$  PATH=PATH=/usr/local/git/bin:~/bin:/Library/Frameworks/Python.framework/Versions/Current/bin:/opt/local/bin:/opt/local/sbin:/usr/local/texlive/2012/bin/universal-darwin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/git/bin:/usr/local/go/bin
~ [4]$  export PATH
~ [5]$  swift
Welcome to Swift version 1.2. Type :help for assistance.
  1>

I'm not sure what in Canopy-64bit/User/bin/ intereferes with Swift, but removing that item on the path seems to do the trick if you want to use the Swift REPL. There doesn't seem to be a problem with the EPD-style entry (/Library/Frameworks/Python.framework...).

Of course, Canopy won't work from this Terminal session, but I'm not sure it's important to have Python REPL and Swift REPL working in the same session.

Upvotes: 4

Santosh
Santosh

Reputation: 1958

It should be

$ xcode-select -switch /Applications/Xcode6-Beta3.app/Contents/Developer

See this article for more 1. Learn Swift by running Scripts

Upvotes: 0

Related Questions