Mac Python "Installation step failed: run postflight script" - python

I'm new to Python development, and in trying to get Aptana Studio Setup, I seemed to have messed up my Python install. So I followed the uninstall MacPython instructions here http://homepages.cwi.nl/~jack/macpython/uninstall.html
...and now I'm trying to install Python again.
From what I can tell, GAE needs you to have Python 2.5. So I'm trying to install the 2.5.4 release from here: http://www.python.org/download/releases/2.5.4/ I've downloaded the dmg and when installing I get the following error:
The installation failed.
The following installation step failed: run postflight script for Fix system Python. Contact the software manufacturer for assistance
In fact, I've tried 2.5, 2.6 and 2.7 dmg installers for python, and I got the same exact error when installing all 3.
I'm running OS 10.6.8
Any ideas? Is there a better/different way to install Python on a Mac?
UPDATE:
When I open up my installer log, here are a few problems that I see:
I got a lot of these type of errors:
Sep 19 14:04:39 thething pkgExtractor[1689]: BomFatalError - cpio read error: bad file format
Sep 19 14:04:39 thething pkgExtractor[1689]: Package Authoring Error: Package "PythonSystemFixes-2.6.pkg" is using a deprecated archive format. Running in compatibility mode.
And at the end I got this:
Sep 19 14:04:40 thething Installer[1641]: run postflight script for Fix system Python
Sep 19 14:04:40 thething runner[1657]: postflight[1722]: Could not find platform independent libraries <prefix>
Sep 19 14:04:40 thething runner[1657]: postflight[1722]: Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Sep 19 14:04:40 thething runner[1657]: postflight[1722]:
Sep 19 14:04:40 thething runner[1657]: postflight[1722]: 'import site' failed; use -v for traceback
Sep 19 14:04:40 thething runner[1657]: postflight[1722]: Traceback (most recent call last):
Sep 19 14:04:40 thething runner[1657]: postflight[1722]: File "/Volumes/Python 2.6.6/Python.mpkg/Contents/Packages/PythonSystemFixes-2.6.pkg/Contents/Resources/postflight", line 16, in <module>
Sep 19 14:04:40 thething runner[1657]: postflight[1722]: import os
Sep 19 14:04:40 thething runner[1657]: postflight[1722]: ImportError: No module named os
Sep 19 14:04:40 thething runner[1657]: postflight[1722]:
Sep 19 14:04:40 thething Installer[1641]: Install failed: The following installation step failed: run postflight script for Fix system Python. Contact the software manufacturer for assistance.
Sep 19 14:04:40 thething Installer[1641]: IFDInstallController 207240 state = 7
Sep 19 14:04:40 thething Installer[1641]: Displaying 'Install Failed' UI.
Sep 19 14:04:40 thething Installer[1641]: 'Install Failed' UI displayed message:'The following installation step failed: run postflight script for Fix system Python. Contact the software manufacturer for assistance.'.

OK, based on your information about /usr/bin/python failing (I was afraid that might be the case!), it appears there are problems with your Apple-supplied system Python. Perhaps you mistakenly deleted something in /System/Library/Frameworks/Python.frameworks, which is where the Apple-supplied Python resides and should never be modified or deleted, instead of /Library/Frameworks/Python.frameworks. Or perhaps you earlier followed the unfortunately misguided advice on the Python wiki here to create a symlink from /Library/Frameworks/Python.frameworks to the system Python framework which can result in an inadvertent corruption of the system Python when installing a new version of Python. The BOMFatalError message in the installer log is normal and can be ignored. Likewise, it is not a problem in itself that the Fix system Python package of the installer fails since it only applies to OS X 10.3. However, it is failing because the system Python is failing and that is a problem.
If you have a Time Machine backup or other backup of your System files, you may be able to properly (and carefully!) restore /System/Library/Python.frameworks/ from a backup. It is difficult but not impossible to extract the necessary files from a Snow Leopard OS X Installer DVD. If you have a similar machine running the same version of OS X, you might be able to copy the files from there. Or do a vanilla install of 10.6 to an unused disk partition. A simpler but imperfect workaround is to just create a symlink from /usr/bin/python and friends to the python.org Python and just wait until you reinstall Snow Leopard or upgrade to Lion (it might be safest to remove that symlink before upgrading). So something like this:
sudo bash
cd /usr/bin
mv python python-DISABLED
ln -s /usr/local/bin/python python
exit

You can develop using more recent Python, as long as you're not using post 2.5 language constructs or packages. (I'm using 2.6.5.)
Official support for Python 2.7 on the way.

Related

Python crashing on MacOS 10.15 Beta (19A582a) with "/usr/lib/libcrypto.dylib"

I ran my Django project with new macOS Catalina and was running fine.
I installed oh_my_zsh then I tried to run the same project it is crashing with the following errors. I uninstalled oh_my_zsh and tried again but it did not worked.
Path: /usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/Resources/Python.app/Contents/MacOS/Python
Identifier: Python
Version: 3.7.4 (3.7.4)
Code Type: X86-64 (Native)
Parent Process: Python [7526]
Responsible: Terminal [7510]
User ID: 501
Date/Time: 2019-10-07 20:59:20.675 +0530
OS Version: Mac OS X 10.15 (19A582a)
Report Version: 12
Anonymous UUID: CB7F20F6-96C0-4F63-9EC5-AFF3E0989687
Time Awake Since Boot: 3000 seconds
System Integrity Protection: enabled
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Application Specific Information:
/usr/lib/libcrypto.dylib
abort() called
Invalid dylib load. Clients should not load the unversioned libcrypto dylib as it does not have a stable ABI.
I just came across the same problem and felt a bit uncomfortable to manually link things around.
I was able to solve the problem by simply
Installing openssl via homebrew:
brew install openssl
Pointing towards the dynamic libraries from openssl via DYLD_LIBRARY_PATH:
export DYLD_LIBRARY_PATH=/usr/local/opt/openssl/lib:$DYLD_LIBRARY_PATH
I've just added that line to my .zshrc.
Edit: According to this question, the usage of DYLD_FALLBACK_LIBRARY_PATH might be preferable over DYLD_LIBRARY_PATH.
Edit 2: As mentioned in a comment below, this should probably be the accepted answer. Simply reinstall the cryptography package.
For me it was enough to re-install Python's cryptography package.
pip uninstall cryptography
pip install cryptography
Caveat: I am not a security expert, and this solution messes with crypto libraries!
I don't think your issue stems from zsh or oh-my-zsh. My best guess: some crypto libraries installed with MacOS 10.15 are incompatible with Homebrew's python3 installation.
Here's what fixed the issue for me
# Install openssl via homebrew.
# Note: According to homebrew, "openssl is keg-only, which means it was
# not symlinked into /usr/local, because Apple has deprecated use of
# OpenSSL in favor of its own TLS and crypto libraries."
brew install openssl
# Symlink those versions into /usr/local/lib, which gets Python to dynamically
# link against those instead of the version in /usr/lib/.
# Got the idea from https://forums.developer.apple.com/thread/119429
cd /usr/local/lib
sudo ln -s /usr/local/Cellar/openssl/1.0.2t/lib/libssl.1.0.0.dylib libssl.dylib
sudo ln -s /usr/local/Cellar/openssl/1.0.2t/lib/libcrypto.1.0.0.dylib libcrypto.dylib
My situation for context:
Recently upgraded to MacOS 10.15
I use python/pip installed via homebrew: brew install python
pip3 was failing with SIGABRT
Header of system error report:
Process: Python [52429]
Path: /usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/Resources/Python.app/Contents/MacOS/Python
Identifier: Python
Version: 3.7.4 (3.7.4)
Code Type: X86-64 (Native)
Parent Process: zsh [43309]
Responsible: iTerm2 [2316]
User ID: 501
Date/Time: 2019-10-09 09:52:18.148 -0700
OS Version: Mac OS X 10.15 (19A583)
Report Version: 12
Bridge OS Version: 4.0 (17P572)
Anonymous UUID:
Sleep/Wake UUID:
Time Awake Since Boot: 9900 seconds
Time Since Wake: 7300 seconds
System Integrity Protection: enabled
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Application Specific Information:
/usr/lib/libcrypto.dylib
abort() called
Invalid dylib load. Clients should not load the unversioned libcrypto dylib as it does not have a stable ABI.
I prefer a combination of #bixel, #Juro Oravec & #honkaboy answers:
brew install openssl
cd /usr/local/lib
sudo ln -s /usr/local/opt/openssl/lib/libssl.dylib libssl.dylib
sudo ln -s /usr/local/opt/openssl/lib/libcrypto.dylib libcrypto.dylib
This way, at least in theory, when updating openssl the dylibs will always point to the latest versions. /usr/local/opt/openssl is actually a link to /usr/local/Cellar/openssl/Cellar/openssl/1.0.2t (the version of openssl installed by brew).
The reason the issue happens is actually explained by brew:
openssl is keg-only, which means it was not symlinked into /usr/local,
because Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries.
Trying to run brew link openssl:
Warning: Refusing to link macOS-provided software: openssl If you need
to have openssl first in your PATH run: echo 'export
PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile
For compilers to find openssl you may need to set: export
LDFLAGS="-L/usr/local/opt/openssl/lib" export
CPPFLAGS="-I/usr/local/opt/openssl/include"
For pkg-config to find openssl you may need to set: export
PKG_CONFIG_PATH="/usr/local/opt/openssl/lib/pkgconfig"
So, basically you need to link them manually.
r.xuan from this Apple Dev thread identified the steps of a workaround for the error
Invalid dylib load. Clients should not load the unversioned libcrypto dylib as it does not have a stable ABI.
by replacing the libssl.dylib and libcrypto.dylib links in /usr/local/lib with links to libs from Homebrew's install of openssl.
The steps are:
Get fresh libs
1) brew update && brew upgrade && brew install openssl
2) cd /usr/local/Cellar/openssl/1.0.2t/lib
3) sudo cp libssl.1.0.0.dylib libcrypto.1.0.0.dylib /usr/local/lib/
Backup the old ones
4) cd /usr/local/lib
5) mv libssl.dylib libssl_bak.dylib
6) mv libcrypto.dylib libcrypto_bak.dylib
Create new links
7) sudo ln -s libssl.1.0.0.dylib libssl.dylib
8) sudo ln -s libcrypto.1.0.0.dylib libcrypto.dylib
I was seeing similar problems with ansible. The culprit was asn1crypto, and the problem has been already fixed.
My solution was to manually remove it and reinstall it with pip:
rm -r /usr/local/lib/python2.7/site-packages/asn1crypto*. This allowed pip to work without problems.
pip install asn1crypto, which installed 1.2.0:
Found existing installation: asn1crypto 0.24.0
Uninstalling asn1crypto-0.24.0:
Successfully uninstalled asn1crypto-0.24.0
Successfully installed asn1crypto-1.2.0
NOTE: You can check if asn1crypto is the culprit by running python in verbose mode, e.g. python -v $(which ansible). In my case it crashed while doing some asn1crypto related imports:
# /usr/local/lib/python2.7/site-packages/asn1crypto/_perf/_big_num_ctypes.pyc matches /usr/local/lib/python2.7/site-packages/asn1crypto/_perf/_big_num_ctypes.py
import asn1crypto._perf._big_num_ctypes # precompiled from /usr/local/lib/python2.7/site-packages/asn1crypto/_perf/_big_num_ctypes.pyc
[1] 59247 abort python -v $(which ansible)
Related: https://github.com/Homebrew/homebrew-core/issues/44996
It must be usage of some dependencies like cryptography
Solution:
cd your-site-packages-path/
vim ./asn1crypto/_int.py
find this line; delete it, and everything is ok
# from ._perf._big_num_ctypes import libcrypto
Here is my problem
Process: Python [85179]
Path: /usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/Resources/Python.app/Contents/MacOS/Python
Identifier: Python
Version: 3.7.4 (3.7.4)
Code Type: X86-64 (Native)
Parent Process: ??? [85161]
Responsible: iTerm2 [11711]
User ID: 501
Date/Time: 2019-10-07 23:00:25.143 +0800
OS Version: Mac OS X 10.15 (19A582a)
Report Version: 12
Bridge OS Version: 3.0 (14Y906)
Anonymous UUID: 32C73ADD-1291-FA0E-DC02-48D539674325
Time Awake Since Boot: 42000 seconds
System Integrity Protection: enabled
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Application Specific Information:
/usr/lib/libcrypto.dylib
abort() called
Invalid dylib load. Clients should not load the unversioned libcrypto dylib as it does not have a stable ABI.
I’m afraid that none of these answers are acceptable to me. Because these answers didn’t fix the cause. Some of them are lucky, or misunderstand, or even wrong. So I’m going to provide my own solution and explain in details for the problem.
Invalid dylib load. Clients should not load the unversioned libcrypto dylib as it does not have a stable ABI.
The root cause is quite clear itself. Your Python was trying to open (by dlopen) an unversioned OpenSSL shared library named libcrypto. Apple doesn’t allow anyone to use it for the security reason since Catalina. So the solution is straightforward. Just using versioning OpenSSL instead.
I write a python script named openlib.py to reproduce the problem.
import sys
from ctypes.util import find_library
from ctypes import CDLL
name = sys.argv[1]
path = find_library(name)
print(f"path: {path}")
lib = CDLL(path)
I use system Python for demo here
$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.15.7
BuildVersion: 19H15
$ /usr/bin/python3 --version
Python 3.8.2
$ ls -al /usr/lib/ | grep 'libcrypto\|libssl'
.rwxr-xr-x 1.1M root 22 Sep 8:29 libcrypto.0.9.7.dylib
.rwxr-xr-x 1.4M root 22 Sep 8:29 libcrypto.0.9.8.dylib
.rwxr-xr-x 1.5M root 22 Sep 8:29 libcrypto.35.dylib
.rwxr-xr-x 1.5M root 22 Sep 8:29 libcrypto.41.dylib
.rwxr-xr-x 1.5M root 22 Sep 8:29 libcrypto.42.dylib
.rwxr-xr-x 1.5M root 22 Sep 8:29 libcrypto.44.dylib
.rwxr-xr-x 32k root 22 Sep 8:29 libcrypto.dylib
.rwxr-xr-x 212k root 22 Sep 8:29 libssl.0.9.7.dylib
.rwxr-xr-x 335k root 22 Sep 8:30 libssl.0.9.8.dylib
.rwxr-xr-x 330k root 22 Sep 8:28 libssl.35.dylib
.rwxr-xr-x 313k root 22 Sep 8:29 libssl.43.dylib
.rwxr-xr-x 300k root 22 Sep 8:29 libssl.44.dylib
.rwxr-xr-x 294k root 22 Sep 8:29 libssl.46.dylib
.rwxr-xr-x 32k root 22 Sep 8:29 libssl.dylib
$ /usr/bin/python3 openlib.py libcrypto
path: /usr/lib/libcrypto.dylib
Abort trap: 6
$ /usr/bin/python3 openlib.py libcrypto.35
path: /usr/lib/libcrypto.35.dylib
$ /usr/bin/python3 openlib.py libcrypto.44
path: /usr/lib/libcrypto.44.dylib
As you can see. Python has crashed with argument libcrypto as following diagnostic report. Look similar, right? Bingo!
Process: Python [97291]
Path: /Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/Resources/Python.app/Contents/MacOS/Python
Identifier: Python
Version: 3.8.2 (3.8.2)
Build Info: python3-73040006000000~117
Code Type: X86-64 (Native)
Parent Process: bash [84388]
Responsible: iTerm2 [7705]
User ID: 501
Date/Time: 2020-12-26 00:28:00.281 +0800
OS Version: Mac OS X 10.15.7 (19H15)
Report Version: 12
Anonymous UUID: 1C43F3DB-1783-4B94-B663-7F7E8D331B56
Time Awake Since Boot: 53000 seconds
System Integrity Protection: enabled
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Application Specific Information:
/usr/lib/libcrypto.dylib
abort() called
Invalid dylib load. Clients should not load the unversioned libcrypto dylib as it does not have a stable ABI.
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x00007fff69bba33a __pthread_kill + 10
1 libsystem_pthread.dylib 0x00007fff69c76e60 pthread_kill + 430
2 libsystem_c.dylib 0x00007fff69b41808 abort + 120
3 libcrypto.dylib 0x00007fff6766b7e4 __report_load + 415
Based on the path of your Python /usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/Resources/Python.app/Contents/MacOS/Python. Apparently, Your Python is installed by Homebrew. I believe Homebrew Python 3 has been linked with keg-only OpenSSL. So It must be some packages that using unversioned OpenSSL. Looking at file ctypes/macholib/dyld.py 2. It searches for any libraries in following directories in the specified order:
DEFAULT_LIBRARY_FALLBACK = [
os.path.expanduser("~/lib"),
"/usr/local/lib",
"/lib",
"/usr/lib",
]
$ /usr/bin/python3
Python 3.8.2 (default, Nov 4 2020, 21:23:28)
[Clang 12.0.0 (clang-1200.0.32.28)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from ctypes.util import find_library
>>> find_library('libcrypto')
'/usr/lib/libcrypto.dylib'
>>>
So the easy fix is linking versioning OpenSSL to the library path in your home directory.
$ pwd
/Users/gasolwu
$ ln -s /usr/lib/libcrypto.44.dylib $HOME/lib/libcrypto.dylib
$ $ ls ~/lib
libcrypto.dylib
After that. Test opening OpenSSL by running the provided script openlib.py. It returns library path successfully without crash.
$ /usr/bin/python3 openlib.py libcrypto
path: /Users/gasolwu/lib/libcrypto.dylib
I use Homebrew Python 3 too. So I fixed it a couple of days ago and have sent a pull request. If you have already upgraded to the latest version of Python and If PR has been merge and the bottle has built and published. Simply run the command with brew reinstall python#3.9 will be the easiest way to fix your problem.
Don’t break your system by disabling SIP and using sudo to overwrite your system OpenSSL.
Don’t install duplicate libraries that waste your disk space. There is no need to install another OpenSSL in any location.
Don't use environment variable DYLD_LIBRARY_PATH as follows. You have to declare every time if you don't add this line to your configuration of the shell. If you do, It will affect every program on your machine.
export DYLD_LIBRARY_PATH=/usr/local/opt/openssl/lib:$DYLD_LIBRARY_PATH
Finally. If you fixed the problem by updating python dependencies. You might be lucky. Some packages have fixed the problem by looking for versioning OpenSSL. But many are not.
Try:
python3 -m pip install oscrypto
Worked for me!
If you're using Kevlar from DevMate, upgrade to 4.3.1, which "Fixed macOS Catalina crash caused by version of libcrypto.dylib".
Looks like it was a Homebrew issue. I did brew reinstall python3 and it worked.
To follow the answers mentioned above, wanted to link libssl.dylib file but found is no such location as below:
/usr/local/Cellar/openssl/1.0.2t/lib/
However as the accepted answer by #bixel found the file in below location
/usr/local/opt/openssl/lib
and it worked for me.
I met the same issue when I was using ctypes.cdll to open /usr/lib/libcrypto.dylib with Python 3.7. However the dylib COULD be opened with Python 2.7.
I installed the latest openssl with brew install, then set the environment variables and created links as what they suggested above, NOTHING good was happened.
After several hours' digging, I found a workaround solution.
I found some libcrypto.X.dylib in /usr as following,
/usr/lib/libcrypto.dylib
/usr/lib/libcrypto.0.9.7.dylib
/usr/lib/libcrypto.0.9.8.dylib
/usr/lib/libcrypto.35.dylib
/usr/lib/libcrypto.41.dylib
/usr/lib/libcrypto.42.dylib
/usr/lib/libcrypto.44.dylib
/usr/local/opt/openssl/lib/libcrypto.1.1.dylib
/usr/local/opt/openssl/lib/libcrypto.dylib
Firstly, I used the followed one to replace that in /usr/lib instead.
os.environ['DYLD_FALLBACK_LIBRARY_PATH'] = '/usr/local/opt/openssl/lib'
It could be loaded but some apis were missing,
AttributeError: dlsym(0x..., ECDH_OpenSSL): symbol not found
I created a link for /usr/lib/libcrypto.X.dylib in my script path.
ln -s /usr/lib/libcrypto.X.dylib lib/libcrypto.dylib
Then add the path to DYLD_FALLBACK_LIBRARY_PATH
os.environ['DYLD_FALLBACK_LIBRARY_PATH'] = 'lib' # It should be a absolute path
At last, it worked.
Use the following steps to solve:
brew update && brew upgrade && brew reinstall openssl
cd /usr/local/Cellar/openssl#1.1/1.1.1g/lib
sudo cp libssl.1.1.1.dylib libcrypto.1.1.1.dylib /usr/local/lib/
sudo ln -s libssl.1.0.0.dylib libssl.dylib
sudo ln -s libcrypto.1.0.0.dylib libcrypto.dylib`

GLIBC 2.14 installation error: forced unwind support is required - RHEL 7.5

I have upgraded my RHEL OS from 6.7 to 7.5. After upgrading, I found some issues when trying to run yum. Below are the details.
# yum repolist
There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:
/lib64/libc.so.6: version `GLIBC_2.14' not found (required by /lib64/libgcc_s.so.1)
Please install a package which provides this module, or
verify that the module is installed correctly.
It's possible that the above module doesn't match the
current version of Python, which is:
2.6.6 (r266:84292, Aug 9 2016, 06:11:56)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-17)]
If you cannot solve this problem yourself, please go to
the yum faq at:
http://yum.baseurl.org/wiki/Faq
After getting this error, I just installed python2.7 and GLIBC 2.14. But when I am trying to install GLIBC 2.14 from my current GLIBC version 2.12, it is throwing some error. Below are the steps that I am using to install GLIBC 2.14:
tar xvfz glibc-2.14.tar.gz
cd glibc-2.14
mkdir build
cd build
../configure --prefix=/opt/glibc-2.14
make
sudo make install
export LD_LIBRARY_PATH=/opt/glibc-2.14/lib:$LD_LIBRARY_PATH
In step5, I am getting error. Below are the details:
# ../configure --prefix=/opt/glibc-2.14
checking for forced unwind support... no
configure: error: forced unwind support is required
I am unaware of this error "unwind support is required".Please let me know how to setup/install forced unwind in Redhat 7.5.
add libc_cv_forced_unwind=yes when configure:
../configure --prefix=/opt/glibc-2.14 libc_cv_forced_unwind=yes
and make

Change default python version from 2.6.6 to 2.7 and also configure django

I am new to linux (Ubuntu) and python (Django). By default there is python 2.6.6 in my linux, I installed python 2.7. In the command prompt when I type python it goes to python 2.6.6, I want to change my default python to 2.7.
Ubuntu might have a Python2.7 package. If so, install that then use that to create a virtualenv and put Django inside that.
I recommend to use pythonbrew which can install and switch between multi Python interpreters in your $HOME without touch your system directories.
BTW, when install python, use the command
pythonbrew install --no-test 2.7.2
to skip unitest could speed up the installation a lot.
It's all about the links, I tell ya. Look at the links. Check the inode's link count for python2.5, python2.6, python2.7, python3.2, etc. Notice those are greater than one.
Just hunt down the duped link to "python", fix by unlink, and relink it. It may be a real link, or just a sym link. unlink with extreme prejudice.
-rwxr-xr-x 2 root admin 12392 Oct 4 2009 /opt/local/bin/python2.5*
-rwxr-xr-x 2 root wheel 12392 Jul 23 17:14 /opt/local/bin/python2.6*
lrwxr-xr-x 1 root wheel 72 Nov 7 2008 /usr/bin/python# -> ../../System/Library/Frameworks/Python.framework/Versions/2.5/bin/python
-rwxrwxr-x 1 root admin 41476 Jul 3 2010 /Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7*
-rwxr-xr-x 3 root wheel 2072216 Jul 27 19:34 /usr/local/bin/python3.2*
The easiest way would be to modify your path and make sure the path to Python 2.7 is before Python 2.6. This is what I have done on my Mac to achieve similar things.
EDIT
I agree with Noufal Ibrahim in the fact about using virtualenv. I would also suggest looking into virutalenv wrapper. However, you still might have trouble using Python 2.7 is your path is not configured correctly, using an Ubuntu package for the install should take care of the path for you. Otherwise to install virtualenv from the bash shell, you can do something along the lines.
$ path/to/python27/python easy_install virutalenv
$ pip install virtualenvwrapper
I believe when installing virtualenv, it will set your PATH for you. You can confirm this by doing:
$which python
This should now show Python 2.7.

easy_install broken on Mac

I have copied my home folder from a Mac OSX 10.5 to a new Mac OSX 10.6. This broke east_intall for binary packages. For example if I use Python 2.5:
> easy_install celery
Searching for celery
Reading http://pypi.python.org/simple/celery/
Reading http://github.com/ask/celery/
Reading http://celeryproject.org
Best match: celery 2.2.7
Downloading http://pypi.python.org/packages/source/c/celery/celery-2.2.7.tar.gz#md5=5826cf891eaa6175cc7aab67818094fe
Processing celery-2.2.7.tar.gz
Running celery-2.2.7/setup.py -q bdist_egg --dist-dir /var/folders/TK/TKwwrl0JEyKrCVteN9D+Jk+++TI/-Tmp-/easy_install-RSjVZt/celery-2.2.7/egg-dist-tmp-w4bMT_
...
In file included from Modules/_multiprocessing/multiprocessing.h:6,
from Modules/_multiprocessing/multiprocessing.c:9:
/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5/Python.h:18:20: error: limits.h: No such file or directory
...
... millions of errors
...
error: Setup script exited with error: command 'gcc' failed with exit status 1
If I use Python 2.6
> easy_install-2.6 celery
Searching for celery
Reading http://pypi.python.org/simple/celery/
Reading http://github.com/ask/celery/
Reading http://celeryproject.org
Best match: celery 2.2.7
Downloading http://pypi.python.org/packages/source/c/celery/celery-2.2.7.tar.gz#md5=5826cf891eaa6175cc7aab67818094fe
Processing celery-2.2.7.tar.gz
Running celery-2.2.7/setup.py -q bdist_egg --dist-dir /var/folders/TK/TKwwrl0JEyKrCVteN9D+Jk+++TI/-Tmp-/easy_install-dCVly4/celery-2.2.7/egg-dist-tmp-PqOUyI
error: Setup script exited with error: Setup script exited with error: Setup script exited with error: Setup script exited with error: Setup script exited with error: Setup script exited with error: Setup script exited with error: Setup script exited with error: Setup script exited with error: Setup script exited with error: Setup script exited with error: Setup script exited with error: Setup script exited with error: Setup script exited with error: Setup script exited with error: Setup script exited with error: Setup script exited with error: Setup script exited with error: Setup script exited with error: Setup script exited with error: Setup script exited with error: Setup script exited with error: /var/folders/TK/TKwwrl0JEyKrCVteN9D+Jk+++TI/-Tmp-/easy_install-dCVly4/celery-2.2.7/temp/easy_install-61UKvH/PasteDeploy-1.5.0/temp/easy_install-ExR4d0/Paste-1.7.5.1/temp/easy_install-OJw80Y/PasteDeploy-1.5.0/temp/easy_install-Zg0wGJ/Paste-1.7.5.1/temp/easy_install-aWn8hm/PasteDeploy-1.5.0/temp/easy_install-1TOXq2/Paste-1.7.5.1/temp/easy_install-r97tJG/PasteDeploy-1.5.0/temp/easy_install-CNdClq/Paste-1.7.5.1/temp/easy_install-XUejp4/PasteDeploy-1.5.0/temp/easy_install-xN6Jd6/Paste-1.7.5.1/temp/easy_install-zFbJOI/PasteDeploy-1.5.0/temp/easy_install-fc2q_2/Paste-1.7.5.1/temp/easy_install-1rTVrG/PasteDeploy-1.5.0/temp/easy_install-rii66v/Paste-1.7.5.1/temp/easy_install-cZBf5J/PasteDeploy-1.5.0/temp/easy_install-ICPv8M/Paste-1.7.5.1/temp/easy_install-RwRQIz/PasteDeploy-1.5.0/temp/easy_install-x74lHT/Paste-1.7.5.1/temp/easy_install-Yf8l74/PasteDeploy-1.5.0/temp/easy_install-fnl5Wt/Paste-1.7.5.1/temp/easy_install-OwWNt9/PasteDeploy-1.5.0/temp/easy_install-WkOs3d/Paste-1.7.5.1/docs/include/reference_header.txt: File name too long
This is not a celery specific question. I get similar errors with lxml, matplotlib, scipy, etc. The problem occurs with all binary packages, not pure python packages. What am I doing wrong?
> which easy_install
/Library/Frameworks/Python.framework/Versions/Current/bin/easy_install
> which easy_install-2.6
/usr/bin/easy_install-2.6
It is difficult to tell for sure with the abbreviated tracebacks you included. One possibility is that the separate Python 2.5 you had installed on Mac OS X 10.5, most likely using a python.org installer, did not get copied over. If so, you either need to install a similar Python 2.5 there or move /Library/Frameworks/Python.frameworks from the old installation. Or you should update to using a newer Python, either a system one or one from python.org or one of the third-party open source distributors for Mac OS X, like MacPorts or homebrew or Fink or ActiveState.
Another possibility is that you need to install the optional MacOSX 10.4u SDK from the Xcode 3 installer for Mac OS X 10.6. If that is the case, you should be seeing error messages that include either 10.3 or 10.4 in them.
Update: So it seems you do have an easy_install installed for the extra python.org or at least for whatever version of Python is pointed to by /Library/Frameworks/Python.framework/Versions/Current. You seem to have to have two separate problems here (with the Python 2.5 and another with the system Python 2.6). At this point, it is difficult for me to guess what either of the problems is without getting a lot more information. It is probably best to clean up and start over.
If you want to remove the old Python 2.5 carried over from your old system, you can follow the instructions here on how to remove a python.org installed Python. If you want to, you can make a copy of it first or rename it instead with something like:
cd /Library/Frameworks/Python.framework/Versions
sudo mv 2.5 2.5-OLD
Consider doing the same for any other Python version there. DO NOT delete or modify any files in /System/Library/Frameworks or /usr/bin. Those directories are part of OS X.
Make sure you clean up your shell profile files, .bash_profile etc, to ensure that your PATH no longer includes this Python. Make you don't have any unexpected PYTHONPATH environment variables defined.
Make sure you don't have any outdated Distutils configurations files in your home directory. Look for and rename or remove things like .pydistutils.cfg.
cd ~
ls -al
Also make sure you don't have any unexpected private packages installed in local directories.
ls -al ~/Library/Python
ls -al ~/.local
Inspect and, if necessary, delete anything in the site-packages directories for the Apple-supplied Pythons:
cd /Library/Python/2.6/site-packages
ls -al
cd /Library/Python/2.5/site-packages
ls -al
Start a new terminal session and verify that all is well.
Decide what versions of Python you want to use with 10.6. If you are OK with using the Apple-suppled 2.6.1 or 2.5.4 versions, then use them. They both come with their own versions of easy_install in /usr/bin.
$ ls -l /usr/bin/python*
-rwxr-xr-x 2 root wheel 86000 Jun 24 2010 /usr/bin/python*
-rwxr-xr-x 5 root wheel 925 Jul 7 2009 /usr/bin/python-config*
lrwxr-xr-x 1 root wheel 75 Nov 7 2010 /usr/bin/python2.5# -> ../../System/Library/Frameworks/Python.framework/Versions/2.5/bin/python2.5
lrwxr-xr-x 1 root wheel 82 Nov 7 2010 /usr/bin/python2.5-config# -> ../../System/Library/Frameworks/Python.framework/Versions/2.5/bin/python2.5-config
lrwxr-xr-x 1 root wheel 75 Nov 7 2010 /usr/bin/python2.6# -> ../../System/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6
lrwxr-xr-x 1 root wheel 82 Nov 7 2010 /usr/bin/python2.6-config# -> ../../System/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6-config
-rwxr-xr-x 2 root wheel 86000 Jun 24 2010 /usr/bin/pythonw*
lrwxr-xr-x 1 root wheel 76 Nov 7 2010 /usr/bin/pythonw2.5# -> ../../System/Library/Frameworks/Python.framework/Versions/2.5/bin/pythonw2.5
lrwxr-xr-x 1 root wheel 76 Nov 7 2010 /usr/bin/pythonw2.6# -> ../../System/Library/Frameworks/Python.framework/Versions/2.6/bin/pythonw2.6
$ ls -l /usr/bin/easy*
-rwxr-xr-x 2 root wheel 925 Jun 30 2009 /usr/bin/easy_install*
-rwxr-xr-x 1 root wheel 421 Jun 30 2009 /usr/bin/easy_install-2.5*
-rwxr-xr-x 1 root wheel 421 Jun 30 2009 /usr/bin/easy_install-2.6*
If you want more recent and up-to-date versions of Python, consider installing the latest Pythons (Python 2.7.2 is the current version of Python 2) from python.org or homebrew, MacPorts, Fink, ActiveState etc. Update your shell PATH as necessary. (For example, the python.org installers by default modify your shell profiles appropriately.)
If the installation doesn't already come with an easy_install (python.org doesn't, some of the others have an optional package to do so), install the Distribute package which will provide an easy_install for it.
Have you installed XCode? It looks like you haven't.

Installing Python modules on OSX using easy_install or setup.py install

I am running Snow Leapord 10.6 and trying to install the following python modules:
numpy
scipy
matplotlib
I am running into problems because OSX contains two version of Python:
/Library/Python/
/System/Library/Frameworks/Python.framework/
It appears that when I execute the following command:
sudo easy_install -U {module}, the modules are being installed to the site-packages directory here:
bash-3.2$ ls -al /Library/Python/2.6/site-packages/
total 688
drwxrwxr-x 12 root admin 408 Aug 24 23:26 .
drwxrwxr-x 3 root admin 102 Feb 11 2010 ..
-rw-rw-r-- 1 root admin 119 Feb 11 2010 README
-rw-r--r-- 1 root admin 267 Aug 24 19:03 easy-install.pth
drwxr-xr-x 5 root admin 170 Aug 24 10:42 nose-0.11.4-py2.6.egg
drwxr-xr-x 38 root admin 1292 Aug 24 15:35 numpy
-rw-r--r-- 1 root admin 1618 Aug 24 15:35 numpy-2.0.0.dev8661-py2.6.egg-info
drwxr-xr-x 16 root admin 544 Aug 24 19:07 numscons
drwxr-xr-x 4 root admin 136 Aug 24 19:03 numscons-0.10.1-py2.6.egg
-rw-r--r-- 1 root admin 265 Aug 24 19:07 numscons-0.12.0dev-py2.6.egg-info
-rw-r--r-- 1 root admin 333959 Aug 23 11:51 setuptools-0.6c11-py2.6.egg
-rw-r--r-- 1 root admin 30 Aug 23 11:51 setuptools.pth
But, when I try to install scipy, I see the following error:
config = setup_module.configuration(*args)
File "scipy/setup.py", line 20, in configuration
config.add_subpackage('special')
File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/numpy/distutils/misc_util.py", line 851, in add_subpackage
caller_level = 2)
File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/numpy/distutils/misc_util.py", line 834, in get_subpackage
caller_level = caller_level + 1)
File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/numpy/distutils/misc_util.py", line 766, in _get_configuration_from_setup_py
('.py', 'U', 1))
File "scipy/special/setup.py", line 14, in <module>
(numpy.__version__, numpy.__file__))
ValueError: numpy >= 1.4 is required (detected 1.2.1 from /System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/numpy/__init__.pyc)
So it appears that it is looking for an older version of numpy in my frameworks directory. I used import to see which version of numpy python was finding:
python -c 'import numpy;print numpy.__version__'
1.2.1
And sure enough, it is looking in the frameworks directory even though I have a new version sitting in:
/Library/Python/2.6/site-packages/
I know import searches your local directory first, and then goes into PYTHONPATH, and then finally looks at sys.path. So I checked these out and I do not have PYTHONPATH set right now, and here is my sys.path:
/Library/Python/2.6/site-packages/setuptools-0.6c11-py2.6.egg
/Library/Python/2.6/site-packages/nose-0.11.4-py2.6.egg
/Library/Python/2.6/site-packages/numscons-0.10.1-py2.6.egg
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python26.zip
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-darwin
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac/lib-scriptpackages
/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-tk
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-old
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload
/Library/Python/2.6/site-packages
/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/PyObjC
/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/wx-2.8-mac-unicode
If I change PYTHONPATH to /Library/Python/2.6/site-packages and then check the numpy revision I get the correct version:
bash-3.2$ python -c 'import numpy; print numpy.__version__'
2.0.0.dev8661
But when I run sudo python setup.py build/install scipy cannot find the right numpy, even though PYTHONPATH has been set.
Can anyone please help me out here?
Found this link that looks like it fixes my problem, but I cant seem to get it to work:
http://andreasjacobsen.com/2008/10/10/using-python-setuptools-on-the-mac/
I think the easiest way would be to use MacPorts to install scipy. Here's an intro, though you probably want py26-scipy.
Have you tried installing with pip? Also, try installing scitools, which should pull those you needed.
The issue is that the easy_install you are calling is the one for the Apple install with the frameworks in /System and the python is /usr/bin/python
To see what python gets installed view the easy_install script and see what the #! line says which python to use.
To get the correct easy_install you will need to install distibute or setuptools for the python in /Library (I would guess this is a python.org one with /usr/local/bin/python ). Then use that easy_install
I would note however that I do use #boocs solution of using Macports althogh if just after scipy etc and no other C libraries then other solutions show here will work, also see Enthought
Can you not just move the old numpy out of the way, temporarily ?
cd /System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python
sudo mv numpy numpy-1.2.1 # mv back if need be
The solution I came up with is the following.
1) Do not use the version of Python that comes pre-installed with OSX. Apple has apparently made some modifications to this and not everything builds. So, you need to install a development version of Python. Right now - I would suggest installing Python 2.7. Here is a blog post about how to do it:
https://medium.com/cs-math/a3eb146ebfb5
2) Once you have installed Python, you need to install the fortran libraries for the Scipy/Numpy installation. Use homebrew to do that (Do people really still use MacPorts ???)
http://brew.sh/
3) After you have home brew installed, install fortran
brew install gfortran
4) Now you can install scipy/numpy successfully with pip (Warning - it takes a while)
pip install -U numpy
pip install -U scipy
DONE
I had kind of similar problem, just to same some time of the people with the same issue, if you have two pythons in your system (say python2 and python3) and you wish to install say numpy for the new version (python3) go through these steps:
1- download numpy
2-unzip it
3- in terminal go to the unzipped folder
4-python3 setup.py install

Categories