OS X - Conflict with installed packages in earlier Python installation
posted this on September 29, 2012 15:14
Context: You are now using EPD 2.7.3 or earlier. Previously, using another installation of Python, you had installed some 3rd party packages.
Symptom: Now you are seeing strange error messages when running or importing 3rd party packages.
Rename the directory /Library/Python/2.7/site-packages (either using Finder, or in Terminal.)
Unset the environment variable PYTHONPATH if it is set, at least while running EPD. You can do this within a bash terminal session with the bash command: "unset PYTHONPATH"
1. EPD has, to date, endeavored to be as "vanilla" as possible, in the sense of reproducing exactly the behavior of the python.org distribution, and also including many packages pre-built. On OSX, this "vanilla" behavior has one potentially nasty consequence. While the fix is trivial, the behavior is disconcerting, and for this reason we have removed this behavior from our future installers (currently in beta), preferring "least surprise" over "most compatible".
Specifically, this behavior is to append "/Library/Python/<version>/site-packages" to sys.path. Why?
Since Apple's Python.framework is not modifiable by users, they made the /Library/Python/ directory tree the default destination for user-installed packages when using system Python. All framework builds of Python, including the one from python.org and EPD to date, include that directory on sys.path.
2. Generally, the PYTHONPATH environment variable should only be set to point to your own source code, as a convenience. A well-written 3rd party package should seldom if ever use this method for locating its files. However some 3rd party packages do so, which can cause trouble if you are using more than one Python installation. (Since all Python installations will indirectly check PYTHONPATH when they are looking for an imported module, this can lead to one Python installation referencing a package which was installed in another installation.)