Something went wrong with the homebrew-installed python 2.7.13 installation, so I cleaned out everything installed with homebrew and started from scratch. I still get the error below, referencing a file from PIL (Pillow has been installed with pip). How can I fix this library which seems to be corrupted, yet was just reinstalled?
$ python2 src/ks.py
--- module "start"
Traceback (most recent call last):
File "src/ks.py", line 29, in <module>
from PIL import ImageTk, Image
File "/usr/local/lib/python2.7/site-packages/PIL/ImageTk.py", line 42, in <module>
from . import Image
File "/usr/local/lib/python2.7/site-packages/PIL/Image.py", line 60, in <module>
from . import _imaging as core
ImportError: dlopen(/usr/local/lib/python2.7/site-packages/PIL/_imaging.so, 2): Symbol not found: _clock_gettime
Referenced from: /usr/local/lib/python2.7/site-packages/PIL/.dylibs/liblzma.5.dylib (which was built for Mac OS X 10.12)
Expected in: /usr/lib/libSystem.B.dylib
in /usr/local/lib/python2.7/site-packages/PIL/.dylibs/liblzma.5.dylib
Here's everything I've done getting to this point:
- check brew list
is empty
- install python@2
- list the pip-installed items
- update pip
- uninstall Pillow (just to make sure)
- list the pip-installed items (make sure uninstall succeeded)
- reinstall Pillow
- list the pip-installed items (make sure reinstall succeeded)
- run my script
- I also checked python2 --version
and pip --version
and both confirm the homebrew install is separate from the system-installed python.
+++++++++++++++++++++++++++++++++++++++++
$ brew list
gdbm python readline xz
openssl python@2 sqlite
[user@host]
$ brew install python@2
==> Downloading https://homebrew.bintray.com/bottles/python@2-2.7.14_3.el_capitan.bo
Already downloaded: /Users/benfound/Library/Caches/Homebrew/python@2-2.7.14_3.el_capitan.bottle.1.tar.gz
==> Pouring python@2-2.7.14_3.el_capitan.bottle.1.tar.gz
==> /usr/local/Cellar/python@2/2.7.14_3/bin/python -s setup.py --no-user-cfg install
==> /usr/local/Cellar/python@2/2.7.14_3/bin/python -s setup.py --no-user-cfg install
==> /usr/local/Cellar/python@2/2.7.14_3/bin/python -s setup.py --no-user-cfg install
==> 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
==> Summary
/usr/local/Cellar/python@2/2.7.14_3: 4,602 files, 81.9MB
[user@host]
$ pip list
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
Pillow (5.1.0)
pip (9.0.3)
setuptools (38.5.2)
wheel (0.30.0)
You are using pip version 9.0.3, however version 10.0.0 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
[user@host]
$ pip install --upgrade pip
Collecting pip
Downloading https://files.pythonhosted.org/packages/62/a1/0d452b6901b0157a0134fd27ba89bf95a857fbda64ba52e1ca2cf61d8412/pip-10.0.0-py2.py3-none-any.whl (1.3MB)
100% |████████████████████████████████| 1.3MB 641kB/s
Installing collected packages: pip
Found existing installation: pip 9.0.3
Uninstalling pip-9.0.3:
Successfully uninstalled pip-9.0.3
Successfully installed pip-10.0.0
[user@host]
$ pip uninstall Pillow
Uninstalling Pillow-5.1.0:
Would remove:
/usr/local/lib/python2.7/site-packages/PIL/*
/usr/local/lib/python2.7/site-packages/Pillow-5.1.0.dist-info/*
Proceed (y/n)? y
Successfully uninstalled Pillow-5.1.0
[user@host]
$ pip list
Package Version
---------- -------
pip 10.0.0
setuptools 38.5.2
wheel 0.30.0
[user@host]
$ pip install Pillow
Collecting Pillow
Downloading https://files.pythonhosted.org/packages/df/aa/a25f211a4686f363d8ca5a1752c43a8f42459e70af13e20713d3e636f0af/Pillow-5.1.0-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (3.6MB)
100% |████████████████████████████████| 3.6MB 2.8MB/s
Installing collected packages: Pillow
Successfully installed Pillow-5.1.0
[user@host]
$ pip list
Package Version
---------- -------
Pillow 5.1.0
pip 10.0.0
setuptools 38.5.2
wheel 0.30.0
[user@host]
$ python2 src/ks.py
--- module "start"
Traceback (most recent call last):
File "src/ks.py", line 29, in <module>
from PIL import ImageTk, Image
File "/usr/local/lib/python2.7/site-packages/PIL/ImageTk.py", line 42, in <module>
from . import Image
File "/usr/local/lib/python2.7/site-packages/PIL/Image.py", line 60, in <module>
from . import _imaging as core
ImportError: dlopen(/usr/local/lib/python2.7/site-packages/PIL/_imaging.so, 2): Symbol not found: _clock_gettime
Referenced from: /usr/local/lib/python2.7/site-packages/PIL/.dylibs/liblzma.5.dylib (which was built for Mac OS X 10.12)
Expected in: /usr/lib/libSystem.B.dylib
in /usr/local/lib/python2.7/site-packages/PIL/.dylibs/liblzma.5.dylib
[user@host]
I checked to make sure xcode-select CLI tools are installed, and deleted and reinstalled them to make sure...
$ xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
[user@host]
$ rm -rf /Library/Developer/CommandLineTools/
[user@host]
$ sudo !!
sudo rm -rf /Library/Developer/CommandLineTools/
Password:
[user@host]
$ xcode-select --install
xcode-select: note: install requested for command line developer tools
[user@host]
I've also tried brew doctor
, which gave an issue with the PATH
, which I fixed with an update to .bash_profile:
[user@host]
$ echo $PATH
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/local/git/bin
$ brew doctor
...(snip)
Warning: You have unlinked kegs in your Cellar
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
python
Warning: /usr/bin occurs before /usr/local/bin
This means that system-provided programs will be used instead of those
provided by Homebrew. The following tools exist at both paths:
...(snip)
Consider setting your PATH so that /usr/local/bin
occurs before /usr/bin. Here is a one-liner:
echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.bash_profile
[user@host]
$ echo $PATH
/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/local/git/bin
... but the same error still persists. What is the corrupted module or library, and how do I fix it? Does something need to be repaired in the system-level python install, or does the OS need to be reinstalled?
This is using OS X 10.11.6 (El Capitan). Upgrading is not currently an option (to 10.12.x or higher). I recently tried running the newest version of xcode on this host, however it wasn't supported by the OS and I deleted the app after finding this out. I'd consider it realistic that this could have corrupted something, but I already reinstalled the xcode tools.