Symptom:
- Canopy: If user has installed python2 or python3 via Homebrew (or another package with gdbm as a dependency), then they may encounter an error in Canopy whereby clicking the Editor button from the Welcome Screen results in an immediate crash. This will also be encountered anytime the Editor window is not open but a file is opened that would normally open the Editor window - e.g. opening an IPython notebook.
- EDM: Any code that imports gdbm that is executed from an EDM python 2.7 environment on macOS may encounter one of two errors:
- If gdbm has been installed via Homebrew (usually as a dependency of a python2 or python3 installation) the user will see an error similar to the following:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: dlopen(/Users/<username>/.edm/envs/<env_name>/lib/python2.7/lib-dynload/gdbm.so, 2): Symbol not found: _gdbm_errno
Referenced from: /Users/<username>/.edm/envs/<env_name>/lib/python2.7/lib-dynload/gdbm.so
Expected in: /usr/local/opt/gdbm/lib/libgdbm.4.dylib
in /Users/<username>/.edm/envs/<env_name>/lib/python2.7/lib-dynload/gdbm.so - If gdbm has not been installed via Homebrew instead the error will be:
ImportError: dlopen(/Users/<username>/.edm/envs/test1/lib/python2.7/lib-dynload/gdbm.so, 2): Library not loaded: /usr/local/opt/gdbm/lib/libgdbm.4.dylib
Referenced from: /Users/<username>/.edm/envs/test1/lib/python2.7/lib-dynload/gdbm.so
Reason: image not found
- If gdbm has been installed via Homebrew (usually as a dependency of a python2 or python3 installation) the user will see an error similar to the following:
Cause:
The underlying cause to these issues is a bug in the python 2.7 master build used as the Canopy runtime as well as the python runtime that gets installed to new python 2.7 EDM environments. This issue does not affect Windows users, Linux users, nor does it affect python3 runtimes installed via EDM on macOS.
Solution(s):
We are investigating a way to address the issue in our macOS python 2.7 master build, however we do not currently have an ETA for a fix. In the meantime there are a number of workarounds to address this issue.
1. If you have Homebrew installed and have previously installed python, python3, or a python package such as pygame then those installations will have installed the package gdbm. The simplest solution is to uninstall gdbm with Homebrew:
brew uninstall gdbm
2. If you have Homebrew installed but require the gdbm package to be installed then you may be able to downgrade gdbm. This issue only occurs with gdbm version 1.14 or higher installed via Homebrew. The versions listed below have been tested to work properly; copy one of the following urls and substitute it into the command below:
- gdbm 1.13:
https://raw.githubusercontent.com/Homebrew/homebrew-core/6938c5e3ed0b91bd63de7035b5d5afb57b5942a4/Formula/gdbm.rb
- gdbm 1.12:
https://raw.githubusercontent.com/Homebrew/homebrew-core/febb0fca0a28bf93502751f4671effabdecb55b4/Formula/gdbm.rb
- gdbm 1.11:
https://raw.githubusercontent.com/Homebrew/homebrew-core/f4bd9ce4b511d7fb87f464865077112b4ef1a77f/Formula/gdbm.rb
brew unlink gdbm && brew install <URL>
3. If you do not have Homebrew installed you can address this issue by manually deleting the gdbm.so file from the Canopy python 2.7 runtime or the EDM python 2.7 environment. Note that this file will need to be deleted each time you create a python 2.7 environment with EDM.
Examples:
To remove the file from a python 2.7 EDM environment called test-env:
rm $HOME/.edm/envs/test-env/lib/python2.7/lib-dynload/gdbm.so
To remove the file from the Canopy python 2.7 runtime:
mv /Applications/Canopy.app/appdata/canopy-<version.build.architecture>/Canopy.app/Contents/lib/python2.7/lib-dynload/gdbm.so /Applications/Canopy.app/appdata/canopy-<version.build.architecture>/Canopy.app/Contents/lib/python2.7/lib-dynload/gdbm.so.back
Note: For the command shown above you may want to use tab-completion in your terminal as you will need to enter the exact canopy version, build, and architecture for your system. For the latest version of Canopy on macOS the full path will be:
/Applications/Canopy.app/appdata/canopy-2.1.9.3717.macosx-x86_64/Canopy.app/Contents/lib/python2.7/lib-dynload/gdbm.so
Comments