Mix up swifts using Homebrew install and REPL issues


(Wyattb) #1

I have lates XCode (Version 9.4.1 (9F2000)), but never really used it. So I decided to play with Swift and installed it using brew. When I start REPL swift I get barf of Errors such as below:

$ swift   ## Note this is the /usr/bin/swift.
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Resources/Python/lldb/__init__.py", line 98, in <module>
    import six
ImportError: No module named six
Traceback (most recent call last):
  File "<string>", line 1, in <module>
NameError: name 'run_one_line' is not defined
Traceback (most recent call last):
  File "<string>", line 1, in <module>
NameError: name 'run_one_line' is not defined
Traceback (most recent call last):
  File "<string>", line 1, in <module>
NameError: name 'run_one_line' is not defined

When I run brew info swift It shows message below. Obviously installed someplace else and runs fine from the Cellar. How do I fix this and also get Xcode to to recognize it as the command line tools in preferences.

$ brew info swift
swift: stable 4.1.3 (bottled) [keg-only]
High-performance system programming language
https://github.com/apple/swift
/usr/local/Cellar/swift/4.1.3 (1,452 files, 1.9GB)
  Poured from bottle on 2018-09-04 at 19:56:04
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/swift.rb
==> Dependencies
Build: cmake ✘, ninja ✘
==> Requirements
Build: xcode ✔
==> Caveats
swift is keg-only, which means it was not symlinked into /usr/local,
because Apple's CLT package contains Swift.

/usr/local/Cellar/swift/4.1.3/Swift-4.1.3.xctoolchain/usr/bin$ swift  <--- this runs fine.

(Wyattb) #2

UPDATE: I uninstalled the brew installed swift. Same issues with running swift from command line.


(Joe Groff) #3

Do you also have Python installed through brew? There are some known bad interactions between a brew-installed Python and lldb.


(Goffredo Marocchi) #4

Do you have more on this? I do have python installed through brew, but mostly always code in Xcode (or Xcode playgrounds), so I am quite curious and tempted to switch python off brew. Has this been raised already on that project by the way?


(Keith Smiley) #5

Here's some more context on the python issue. https://forums.swift.org/t/repl-ergonomics/14347 this is very likely a lldb issue, not a python / homebrew issue.


(Joe Groff) #6

Also: Swift REPL starts with error when homebrew python is installed


(Keith Smiley) #7

As far as I know there isn't a bug on the JIRA for this. Is that still true? I'd be happy to try and investigate a fix for this one.


(Joe Groff) #8

I couldn't find a JIRA either, though we have rdar://problem/32112532 internally.


(Wyattb) #9
Here is brew info dump of what I have installed. both python2 and python3. So ya, the confusing world of python versions.

    ~$ which python
    /usr/local/bin/python
    ~$ ls -lsa /usr/local/bin/python
    0 lrwxr-xr-x  1 user  admin  36 Jun 12 19:30 /usr/local/bin/python -> ../Cellar/python@2/2.7.15/bin/python

    ~$ which python3
    /usr/local/bin/python3
    ~$ ls -lsa /usr/local/bin/python3
    0 lrwxr-xr-x  1 root  wheel  69 Oct 29  2017 /usr/local/bin/python3 -> ../../../Library/Frameworks/Python.framework/Versions/3.6/bin/python3
   ~$

~$ brew info python  
python: stable 3.7.0 (bottled), HEAD
Interpreted, interactive, object-oriented programming language
https://www.python.org/
/usr/local/Cellar/python/3.6.5 (4,798 files, 99.9MB)
  Poured from bottle on 2018-06-15 at 21:23:48
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/python.rb
==> Dependencies
Build: pkg-config ✔, sphinx-doc ✘
Required: gdbm ✘, openssl ✔, readline ✘, sqlite ✔, xz ✔
Optional: tcl-tk ✘
==> Options
--with-tcl-tk
  Use Homebrew's Tk instead of macOS Tk (has optional Cocoa and threads support)
--HEAD
  Install HEAD version
==> Caveats
Python has been installed as
  /usr/local/bin/python3

Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to
`python3`, `python3-config`, `pip3` etc., respectively, have been installed into
  /usr/local/opt/python/libexec/bin

If you need Homebrew's Python 2.7 run
  brew install python@2

Pip, setuptools, and wheel have been installed. To update them run
  pip3 install --upgrade pip setuptools wheel

You can install Python packages with
  pip3 install <package>
They will install into the site-package directory
  /usr/local/lib/python3.7/site-packages

See: https://docs.brew.sh/Homebrew-and-Python


$
~$ brew info python2
python@2: stable 2.7.15 (bottled), HEAD
Interpreted, interactive, object-oriented programming language
https://www.python.org/
/usr/local/Cellar/python@2/2.7.15 (4,805 files, 85.0MB) *
  Poured from bottle on 2018-06-12 at 19:30:21
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/python@2.rb
==> Dependencies
Build: pkg-config ✔, sphinx-doc ✘
Required: gdbm ✘, openssl ✔, readline ✘, sqlite ✔
Optional: tcl-tk ✘
==> Options
--with-tcl-tk
  Use Homebrew's Tk instead of macOS Tk (has optional Cocoa and threads support)
--HEAD
  Install HEAD version
==> Caveats
Pip and setuptools have been installed. To update them
  pip install --upgrade pip setuptools

You can install Python packages with
  pip install <package>

They will install into the site-package directory
  /usr/local/lib/python2.7/site-packages

See: https://docs.brew.sh/Homebrew-and-Python

$
~$ brew info python3
python: stable 3.7.0 (bottled), HEAD
Interpreted, interactive, object-oriented programming language
https://www.python.org/
/usr/local/Cellar/python/3.6.5 (4,798 files, 99.9MB)
  Poured from bottle on 2018-06-15 at 21:23:48
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/python.rb
==> Dependencies
Build: pkg-config ✔, sphinx-doc ✘
Required: gdbm ✘, openssl ✔, readline ✘, sqlite ✔, xz ✔
Optional: tcl-tk ✘
==> Options
--with-tcl-tk
  Use Homebrew's Tk instead of macOS Tk (has optional Cocoa and threads support)
--HEAD
  Install HEAD version
==> Caveats
Python has been installed as
  /usr/local/bin/python3

Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to
`python3`, `python3-config`, `pip3` etc., respectively, have been installed into
  /usr/local/opt/python/libexec/bin

If you need Homebrew's Python 2.7 run
  brew install python@2

Pip, setuptools, and wheel have been installed. To update them run
  pip3 install --upgrade pip setuptools wheel

You can install Python packages with
  pip3 install <package>
They will install into the site-package directory
  /usr/local/lib/python3.7/site-packages

See: https://docs.brew.sh/Homebrew-and-Python