I am trying to install the MySQL-python on MAC OS 10.6 (Snow leopard, 64 bit). I followed the steps:
1. Installed MySQL for Mac OS X ver. 10.6 (x86, 64-bit), DMG Archive.
2. Downloaded MySQL-python-1.2.3c1.tar.gz and unzipped it
3. CD to MySQL-python-1.2.3c1 and built it as:
ARCHFLAGS="-arch x86_64" python setup.py build (see output bnelow)
4. Installed it as:
ARCHFLAGS="-arch x86_64" python setup.py install
5. But when I tried to import MySQLdb to python, I am getting error message
import MySQLdb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "build/bdist.macosx-10.3-x86_64/egg/MySQLdb/__init__.py", line 19, in <module>
File "build/bdist.macosx-10.3-x86_64/egg/_mysql.py", line 7, in <module>
File "build/bdist.macosx-10.3-x86_64/egg/_mysql.py", line 6, in __bootstrap__
ImportError: dlopen(/Users/krokodil/.python-eggs/MySQL_python-1.2.3c1-py2.6-macosx-10.3-x86_64.egg-tmp/_mysql.so, 2): no suitable image found. Did find:
/Users/krokodil/.python-eggs/MySQL_python-1.2.3c1-py2.6-macosx-10.3-x86_64.egg-tmp/_mysql.so: mach-o, but wrong architecture
This "macosx-10.3-x86_64" is bothering me - it seems that somehow the build/install thought that I am still on Mac OS 10.3. Please also see Build and Install capture below.
It also using /Developer/SDKs/MacOSX10.4u.sdk compiler, not /Developer/SDKs/MacOSX10.6.sdk
I am using fresh install of Python 2.6.4.
I saw people having probles. Anyone found a good solution?
Thank you
Vlad
BUILD
krokodil:MySQL-python-1.2.3c1 krokodil$ ARCHFLAGS="-arch x86_64" python setup.py build
running build
running build_py
creating build
creating build/lib.macosx-10.3-x86_64-2.6
copying _mysql_exceptions.py -> build/lib.macosx-10.3-x86_64-2.6
creating build/lib.macosx-10.3-x86_64-2.6/MySQLdb
copying MySQLdb/__init__.py -> build/lib.macosx-10.3-x86_64-2.6/MySQLdb
copying MySQLdb/converters.py -> build/lib.macosx-10.3-x86_64-2.6/MySQLdb
copying MySQLdb/connections.py -> build/lib.macosx-10.3-x86_64-2.6/MySQLdb
copying MySQLdb/cursors.py -> build/lib.macosx-10.3-x86_64-2.6/MySQLdb
copying MySQLdb/release.py -> build/lib.macosx-10.3-x86_64-2.6/MySQLdb
copying MySQLdb/times.py -> build/lib.macosx-10.3-x86_64-2.6/MySQLdb
creating build/lib.macosx-10.3-x86_64-2.6/MySQLdb/constants
copying MySQLdb/constants/__init__.py -> build/lib.macosx-10.3-x86_64-2.6/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.macosx-10.3-x86_64-2.6/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.3-x86_64-2.6/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.macosx-10.3-x86_64-2.6/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.3-x86_64-2.6/MySQLdb/constants
copying MySQLdb/constants/REFRESH.py -> build/lib.macosx-10.3-x86_64-2.6/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.3-x86_64-2.6/MySQLdb/constants
running build_ext
building '_mysql' extension
creating build/temp.macosx-10.3-x86_64-2.6
gcc-4.0 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -O3 -Dversion_info=(1,2,3,'gamma',1) -D__version__=1.2.3c1 -I/usr/local/mysql/include -I/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -c _mysql.c -o build/temp.macosx-10.3-x86_64-2.6/_mysql.o -g -Os -arch x86_64 -fno-common -D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -DIGNORE_SIGHUP_SIGQUIT -DDONT_DECLARE_CXA_PURE_VIRTUAL
In file included from _mysql.c:36:
/usr/local/mysql/include/my_config.h:1053:1: warning: "HAVE_WCSCOLL" redefined
In file included from /Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/Python.h:8,
from pymemcompat.h:10,
from _mysql.c:29:
/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/pyconfig.h:805:1: warning: this is the location of the previous definition
gcc-4.0 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -g -bundle -undefined dynamic_lookup -arch x86_64 build/temp.macosx-10.3-x86_64-2.6/_mysql.o -L/usr/local/mysql/lib -lmysqlclient_r -lz -lm -lmygcc -o build/lib.macosx-10.3-x86_64-2.6/_mysql.so
INSTALL
krokodil:MySQL-python-1.2.3c1 krokodil$ ARCHFLAGS="-arch x86_64" python setup.py install
running install
running bdist_egg
running egg_info
writing MySQL_python.egg-info/PKG-INFO
writing top-level names to MySQL_python.egg-info/top_level.txt
writing dependency_links to MySQL_python.egg-info/dependency_links.txt
reading manifest file 'MySQL_python.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'MySQL_python.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.3-x86_64/egg
running install_lib
running build_py
copying MySQLdb/release.py -> build/lib.macosx-10.3-x86_64-2.6/MySQLdb
running build_ext
creating build/bdist.macosx-10.3-x86_64
creating build/bdist.macosx-10.3-x86_64/egg
copying build/lib.macosx-10.3-x86_64-2.6/_mysql.so -> build/bdist.macosx-10.3-x86_64/egg
copying build/lib.macosx-10.3-x86_64-2.6/_mysql_exceptions.py -> build/bdist.macosx-10.3-x86_64/egg
creating build/bdist.macosx-10.3-x86_64/egg/MySQLdb
copying build/lib.macosx-10.3-x86_64-2.6/MySQLdb/__init__.py -> build/bdist.macosx-10.3-x86_64/egg/MySQLdb
copying build/lib.macosx-10.3-x86_64-2.6/MySQLdb/connections.py -> build/bdist.macosx-10.3-x86_64/egg/MySQLdb
creating build/bdist.macosx-10.3-x86_64/egg/MySQLdb/constants
copying build/lib.macosx-10.3-x86_64-2.6/MySQLdb/constants/__init__.py -> build/bdist.macosx-10.3-x86_64/egg/MySQLdb/constants
copying build/lib.macosx-10.3-x86_64-2.6/MySQLdb/constants/CLIENT.py -> build/bdist.macosx-10.3-x86_64/egg/MySQLdb/constants
copying build/lib.macosx-10.3-x86_64-2.6/MySQLdb/constants/CR.py -> build/bdist.macosx-10.3-x86_64/egg/MySQLdb/constants
copying build/lib.macosx-10.3-x86_64-2.6/MySQLdb/constants/ER.py -> build/bdist.macosx-10.3-x86_64/egg/MySQLdb/constants
copying build/lib.macosx-10.3-x86_64-2.6/MySQLdb/constants/FIELD_TYPE.py -> build/bdist.macosx-10.3-x86_64/egg/MySQLdb/constants
copying build/lib.macosx-10.3-x86_64-2.6/MySQLdb/constants/FLAG.py -> build/bdist.macosx-10.3-x86_64/egg/MySQLdb/constants
copying build/lib.macosx-10.3-x86_64-2.6/MySQLdb/constants/REFRESH.py -> build/bdist.macosx-10.3-x86_64/egg/MySQLdb/constants
copying build/lib.macosx-10.3-x86_64-2.6/MySQLdb/converters.py -> build/bdist.macosx-10.3-x86_64/egg/MySQLdb
copying build/lib.macosx-10.3-x86_64-2.6/MySQLdb/cursors.py -> build/bdist.macosx-10.3-x86_64/egg/MySQLdb
copying build/lib.macosx-10.3-x86_64-2.6/MySQLdb/release.py -> build/bdist.macosx-10.3-x86_64/egg/MySQLdb
copying build/lib.macosx-10.3-x86_64-2.6/MySQLdb/times.py -> build/bdist.macosx-10.3-x86_64/egg/MySQLdb
byte-compiling build/bdist.macosx-10.3-x86_64/egg/_mysql_exceptions.py to _mysql_exceptions.pyc
byte-compiling build/bdist.macosx-10.3-x86_64/egg/MySQLdb/__init__.py to __init__.pyc
byte-compiling build/bdist.macosx-10.3-x86_64/egg/MySQLdb/connections.py to connections.pyc
byte-compiling build/bdist.macosx-10.3-x86_64/egg/MySQLdb/constants/__init__.py to __init__.pyc
byte-compiling build/bdist.macosx-10.3-x86_64/egg/MySQLdb/constants/CLIENT.py to CLIENT.pyc
byte-compiling build/bdist.macosx-10.3-x86_64/egg/MySQLdb/constants/CR.py to CR.pyc
byte-compiling build/bdist.macosx-10.3-x86_64/egg/MySQLdb/constants/ER.py to ER.pyc
byte-compiling build/bdist.macosx-10.3-x86_64/egg/MySQLdb/constants/FIELD_TYPE.py to FIELD_TYPE.pyc
byte-compiling build/bdist.macosx-10.3-x86_64/egg/MySQLdb/constants/FLAG.py to FLAG.pyc
byte-compiling build/bdist.macosx-10.3-x86_64/egg/MySQLdb/constants/REFRESH.py to REFRESH.pyc
byte-compiling build/bdist.macosx-10.3-x86_64/egg/MySQLdb/converters.py to converters.pyc
byte-compiling build/bdist.macosx-10.3-x86_64/egg/MySQLdb/cursors.py to cursors.pyc
byte-compiling build/bdist.macosx-10.3-x86_64/egg/MySQLdb/release.py to release.pyc
byte-compiling build/bdist.macosx-10.3-x86_64/egg/MySQLdb/times.py to times.pyc
creating stub loader for _mysql.so
byte-compiling build/bdist.macosx-10.3-x86_64/egg/_mysql.py to _mysql.pyc
creating build/bdist.macosx-10.3-x86_64/egg/EGG-INFO
copying MySQL_python.egg-info/PKG-INFO -> build/bdist.macosx-10.3-x86_64/egg/EGG-INFO
copying MySQL_python.egg-info/SOURCES.txt -> build/bdist.macosx-10.3-x86_64/egg/EGG-INFO
copying MySQL_python.egg-info/dependency_links.txt -> build/bdist.macosx-10.3-x86_64/egg/EGG-INFO
copying MySQL_python.egg-info/top_level.txt -> build/bdist.macosx-10.3-x86_64/egg/EGG-INFO
writing build/bdist.macosx-10.3-x86_64/egg/EGG-INFO/native_libs.txt
zip_safe flag not set; analyzing archive contents...
creating dist
creating 'dist/MySQL_python-1.2.3c1-py2.6-macosx-10.3-x86_64.egg' and adding 'build/bdist.macosx-10.3-x86_64/egg' to it
removing 'build/bdist.macosx-10.3-x86_64/egg' (and everything under it)
Processing MySQL_python-1.2.3c1-py2.6-macosx-10.3-x86_64.egg
Removing /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/MySQL_python-1.2.3c1-py2.6-macosx-10.3-x86_64.egg
Copying MySQL_python-1.2.3c1-py2.6-macosx-10.3-x86_64.egg to /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages
Removing MySQL-python 1.2.3c1 from easy-install.pth file
Adding MySQL-python 1.2.3c1 to easy-install.pth file
Installed /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/MySQL_python-1.2.3c1-py2.6-macosx-10.3-x86_64.egg
Processing dependencies for MySQL-python==1.2.3c1
Finished processing dependencies for MySQL-python==1.2.3c1
The python 2.6.4 you are using is 32-bit only (definitely true if you downloaded the OS X installer from python.org). You can't override the architecture for extension modules; they have to be compatible with the base python. The 10.3 shows up because the python you are using was built with a deployment target of 10.3 as it is designed to run on multiple versions of OS X. If you want to use a 64-bit version of MySQL, you'll need to use a 64-bit version of python, like the Apple-suppled python 2.6.1.
Related
I am trying to get python-pptx installed for Python 3 on a server machine (Red Hat 4.1.2-52). I'm having some trouble installing its dependency, lxml. I've tried to install all of the dependencies separately (as suggested here).
# sudo yum install -y gcc libxml2 libxml2-devel libxslt libxslt-devel python-devel
Setting up Install Process
Package gcc-4.1.2-55.el5.x86_64 already installed and latest version
Package libxml2-2.6.26-2.1.25.0.1.el5_11.x86_64 already installed and latest version
Package libxml2-2.6.26-2.1.25.0.1.el5_11.i386 already installed and latest version
Package libxml2-devel-2.6.26-2.1.25.0.1.el5_11.x86_64 already installed and latest version
Package libxml2-devel-2.6.26-2.1.25.0.1.el5_11.i386 already installed and latest version
Package libxslt-1.1.17-4.0.1.el5_8.3.x86_64 already installed and latest version
Package libxslt-1.1.17-4.0.1.el5_8.3.i386 already installed and latest version
Package libxslt-devel-1.1.17-4.0.1.el5_8.3.x86_64 already installed and latest version
Package libxslt-devel-1.1.17-4.0.1.el5_8.3.i386 already installed and latest version
Package python-devel-2.4.3-56.el5.x86_64 already installed and latest version
Package python-devel-2.4.3-56.el5.i386 already installed and latest version
Nothing to do
Here's the full traceback from # pip install lxml.
Downloading/unpacking lxml
Downloading lxml-3.4.4.tar.gz (3.5MB): 3.5MB downloaded
Running setup.py (path:/tmp/pip_build_root/lxml/setup.py) egg_info for package lxml
Building lxml version 3.4.4.
Building without Cython.
Using build configuration of libxslt 1.1.17
Minimum required version of libxslt is 1.1.17, found 1.1.23
Building against libxml2/libxslt in the following directory: /usr/lib64
/usr/local/lib/python3.4/distutils/dist.py:260: UserWarning: Unknown distribution option: 'bugtrack_url'
warnings.warn(msg)
warning: no previously-included files found matching '*.py'
Installing collected packages: lxml
Running setup.py install for lxml
Building lxml version 3.4.4.
Building without Cython.
Using build configuration of libxslt 1.1.17
Minimum required version of libxslt is 1.1.17, found 1.1.23
Building against libxml2/libxslt in the following directory: /usr/lib64
building 'lxml.etree' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/include/libxml2 -I/tmp/pip_build_root/lxml/src/lxml/includes -I/usr/local/include/python3.4m -c src/lxml/lxml.etree.c -o build/temp.linux-x86_64-3.4/src/lxml/lxml.etree.o -w
In file included from src/lxml/lxml.etree.c:239:
/tmp/pip_build_root/lxml/src/lxml/includes/etree_defs.h:19:4: error: #error minimum required version of libxml2 is 2.7.0
/tmp/pip_build_root/lxml/src/lxml/includes/etree_defs.h:28:4: error: #error minimum required version of libxslt is 1.1.23
src/lxml/lxml.etree.c: In function ‘__pyx_pf_4lxml_5etree_9XMLParser___init__’:
src/lxml/lxml.etree.c:103187: error: ‘XML_PARSE_HUGE’ undeclared (first use in this function)
src/lxml/lxml.etree.c:103187: error: (Each undeclared identifier is reported only once
src/lxml/lxml.etree.c:103187: error: for each function it appears in.)
src/lxml/lxml.etree.c: In function ‘__pyx_pf_4lxml_5etree_10Schematron_6__call__’:
src/lxml/lxml.etree.c:177038: error: ‘XML_SCHEMATRON_OUT_ERROR’ undeclared (first use in this function)
/usr/local/lib/python3.4/distutils/dist.py:260: UserWarning: Unknown distribution option: 'bugtrack_url'
warnings.warn(msg)
error: command 'gcc' failed with exit status 1
Complete output from command /usr/local/bin/python3.4 -c "import setuptools, tokenize;__file__='/tmp/pip_build_root/lxml/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-mrgef1x6-record/install-record.txt --single-version-externally-managed --compile:
Building lxml version 3.4.4.
Building without Cython.
Using build configuration of libxslt 1.1.17
Minimum required version of libxslt is 1.1.17, found 1.1.23
Building against libxml2/libxslt in the following directory: /usr/lib64
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.4
creating build/lib.linux-x86_64-3.4/lxml
copying src/lxml/builder.py -> build/lib.linux-x86_64-3.4/lxml
copying src/lxml/pyclasslookup.py -> build/lib.linux-x86_64-3.4/lxml
copying src/lxml/ElementInclude.py -> build/lib.linux-x86_64-3.4/lxml
copying src/lxml/doctestcompare.py -> build/lib.linux-x86_64-3.4/lxml
copying src/lxml/__init__.py -> build/lib.linux-x86_64-3.4/lxml
copying src/lxml/usedoctest.py -> build/lib.linux-x86_64-3.4/lxml
copying src/lxml/_elementpath.py -> build/lib.linux-x86_64-3.4/lxml
copying src/lxml/cssselect.py -> build/lib.linux-x86_64-3.4/lxml
copying src/lxml/sax.py -> build/lib.linux-x86_64-3.4/lxml
creating build/lib.linux-x86_64-3.4/lxml/includes
copying src/lxml/includes/__init__.py -> build/lib.linux-x86_64-3.4/lxml/includes
creating build/lib.linux-x86_64-3.4/lxml/html
copying src/lxml/html/html5parser.py -> build/lib.linux-x86_64-3.4/lxml/html
copying src/lxml/html/soupparser.py -> build/lib.linux-x86_64-3.4/lxml/html
copying src/lxml/html/builder.py -> build/lib.linux-x86_64-3.4/lxml/html
copying src/lxml/html/ElementSoup.py -> build/lib.linux-x86_64-3.4/lxml/html
copying src/lxml/html/_setmixin.py -> build/lib.linux-x86_64-3.4/lxml/html
copying src/lxml/html/defs.py -> build/lib.linux-x86_64-3.4/lxml/html
copying src/lxml/html/diff.py -> build/lib.linux-x86_64-3.4/lxml/html
copying src/lxml/html/_diffcommand.py -> build/lib.linux-x86_64-3.4/lxml/html
copying src/lxml/html/formfill.py -> build/lib.linux-x86_64-3.4/lxml/html
copying src/lxml/html/__init__.py -> build/lib.linux-x86_64-3.4/lxml/html
copying src/lxml/html/usedoctest.py -> build/lib.linux-x86_64-3.4/lxml/html
copying src/lxml/html/clean.py -> build/lib.linux-x86_64-3.4/lxml/html
copying src/lxml/html/_html5builder.py -> build/lib.linux-x86_64-3.4/lxml/html
creating build/lib.linux-x86_64-3.4/lxml/isoschematron
copying src/lxml/isoschematron/__init__.py -> build/lib.linux-x86_64-3.4/lxml/isoschematron
copying src/lxml/lxml.etree.h -> build/lib.linux-x86_64-3.4/lxml
copying src/lxml/lxml.etree_api.h -> build/lib.linux-x86_64-3.4/lxml
copying src/lxml/includes/c14n.pxd -> build/lib.linux-x86_64-3.4/lxml/includes
copying src/lxml/includes/xinclude.pxd -> build/lib.linux-x86_64-3.4/lxml/includes
copying src/lxml/includes/dtdvalid.pxd -> build/lib.linux-x86_64-3.4/lxml/includes
copying src/lxml/includes/xmlerror.pxd -> build/lib.linux-x86_64-3.4/lxml/includes
copying src/lxml/includes/xmlschema.pxd -> build/lib.linux-x86_64-3.4/lxml/includes
copying src/lxml/includes/etreepublic.pxd -> build/lib.linux-x86_64-3.4/lxml/includes
copying src/lxml/includes/xpath.pxd -> build/lib.linux-x86_64-3.4/lxml/includes
copying src/lxml/includes/uri.pxd -> build/lib.linux-x86_64-3.4/lxml/includes
copying src/lxml/includes/xmlparser.pxd -> build/lib.linux-x86_64-3.4/lxml/includes
copying src/lxml/includes/schematron.pxd -> build/lib.linux-x86_64-3.4/lxml/includes
copying src/lxml/includes/tree.pxd -> build/lib.linux-x86_64-3.4/lxml/includes
copying src/lxml/includes/xslt.pxd -> build/lib.linux-x86_64-3.4/lxml/includes
copying src/lxml/includes/htmlparser.pxd -> build/lib.linux-x86_64-3.4/lxml/includes
copying src/lxml/includes/config.pxd -> build/lib.linux-x86_64-3.4/lxml/includes
copying src/lxml/includes/relaxng.pxd -> build/lib.linux-x86_64-3.4/lxml/includes
copying src/lxml/includes/etree_defs.h -> build/lib.linux-x86_64-3.4/lxml/includes
copying src/lxml/includes/lxml-version.h -> build/lib.linux-x86_64-3.4/lxml/includes
creating build/lib.linux-x86_64-3.4/lxml/isoschematron/resources
creating build/lib.linux-x86_64-3.4/lxml/isoschematron/resources/rng
copying src/lxml/isoschematron/resources/rng/iso-schematron.rng -> build/lib.linux-x86_64-3.4/lxml/isoschematron/resources/rng
creating build/lib.linux-x86_64-3.4/lxml/isoschematron/resources/xsl
copying src/lxml/isoschematron/resources/xsl/RNG2Schtrn.xsl -> build/lib.linux-x86_64-3.4/lxml/isoschematron/resources/xsl
copying src/lxml/isoschematron/resources/xsl/XSD2Schtrn.xsl -> build/lib.linux-x86_64-3.4/lxml/isoschematron/resources/xsl
creating build/lib.linux-x86_64-3.4/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_abstract_expand.xsl -> build/lib.linux-x86_64-3.4/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_svrl_for_xslt1.xsl -> build/lib.linux-x86_64-3.4/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_dsdl_include.xsl -> build/lib.linux-x86_64-3.4/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_schematron_message.xsl -> build/lib.linux-x86_64-3.4/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_schematron_skeleton_for_xslt1.xsl -> build/lib.linux-x86_64-3.4/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/readme.txt -> build/lib.linux-x86_64-3.4/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
running build_ext
building 'lxml.etree' extension
creating build/temp.linux-x86_64-3.4
creating build/temp.linux-x86_64-3.4/src
creating build/temp.linux-x86_64-3.4/src/lxml
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/include/libxml2 -I/tmp/pip_build_root/lxml/src/lxml/includes -I/usr/local/include/python3.4m -c src/lxml/lxml.etree.c -o build/temp.linux-x86_64-3.4/src/lxml/lxml.etree.o -w
In file included from src/lxml/lxml.etree.c:239:
/tmp/pip_build_root/lxml/src/lxml/includes/etree_defs.h:19:4: error: #error minimum required version of libxml2 is 2.7.0
/tmp/pip_build_root/lxml/src/lxml/includes/etree_defs.h:28:4: error: #error minimum required version of libxslt is 1.1.23
src/lxml/lxml.etree.c: In function ‘__pyx_pf_4lxml_5etree_9XMLParser___init__’:
src/lxml/lxml.etree.c:103187: error: ‘XML_PARSE_HUGE’ undeclared (first use in this function)
src/lxml/lxml.etree.c:103187: error: (Each undeclared identifier is reported only once
src/lxml/lxml.etree.c:103187: error: for each function it appears in.)
src/lxml/lxml.etree.c: In function ‘__pyx_pf_4lxml_5etree_10Schematron_6__call__’:
src/lxml/lxml.etree.c:177038: error: ‘XML_SCHEMATRON_OUT_ERROR’ undeclared (first use in this function)
/usr/local/lib/python3.4/distutils/dist.py:260: UserWarning: Unknown distribution option: 'bugtrack_url'
warnings.warn(msg)
error: command 'gcc' failed with exit status 1
Any ideas what I might be doing wrong? Thanks very much in advance!
If anything, this is a duplicate of this post which also went unanswered...but we got slightly different error messages.
I don't use Red Hat, but my recommendation for you is to follow the instructions from here:
sudo yum install make automake gcc gcc-c++ kernel-devel git-core -y
sudo yum install python-devel -y
sudo curl -o /tmp/ez_setup.py https://sources.rhodecode.com/setuptools/raw/bootstrap/ez_setup.py
sudo /usr/bin/python /tmp/ez_setup.py
sudo /usr/bin/easy_install pip
sudo rm setuptools-*.tar.gz
sudo pip install -i https://pypi.rhodecode.com/ --upgrade pip
sudo pip install virtualenv
The idea here is that you would install a virtual environment and work with pip packages under it, which is easy and more reliable in terms of dependencies.
Please don't use sources.rhodecode.com and pypi.rhodecode.com they will soon disappear :) We're no longer mirror our python stuff internally at RhodeCode.
I am having following issue when installing mitmproxy through pip.
I have tried other fixed related to egg error. Here on stack overflow.
Can't install via pip because of egg_info error
pip install matplotlib fails: 'cannot build package freetype; "python setup.py egg_info" failed with error code 1'
104:bin user129856$ sudo pip install mitmproxy
The directory '/Users/alokchoudhary/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/alokchoudhary/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting mitmproxy
/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
Downloading mitmproxy-0.12.1.tar.gz (6.5MB)
100% |████████████████████████████████| 6.5MB 18kB/s
Collecting pyperclip>=1.5.8 (from mitmproxy)
Downloading pyperclip-1.5.11.zip
Collecting pyasn1>0.1.2 (from mitmproxy)
Downloading pyasn1-0.1.8.tar.gz (75kB)
100% |████████████████████████████████| 77kB 827kB/s
Collecting tornado>=4.0.2 (from mitmproxy)
Downloading tornado-4.2.tar.gz (433kB)
100% |████████████████████████████████| 434kB 260kB/s
Collecting lxml>=3.3.6 (from mitmproxy)
Downloading lxml-3.4.4.tar.gz (3.5MB)
100% |████████████████████████████████| 3.5MB 32kB/s
Collecting netlib<0.13,>=0.12 (from mitmproxy)
Downloading netlib-0.12.1.tar.gz (64kB)
100% |████████████████████████████████| 65kB 729kB/s
Complete output from command python setup.py egg_info:
warning: no files found matching 'OpenSSL/RATIONALE'
warning: no previously-included files found matching 'leakcheck'
warning: no previously-included files matching '*.py' found under directory 'leakcheck'
warning: no previously-included files matching '*.pem' found under directory 'leakcheck'
warning: no previously-included files matching '*.pyc' found anywhere in distribution
no previously-included directories found matching 'doc/_build'
zip_safe flag not set; analyzing archive contents...
Installed /private/tmp/pip-build-wOHXdq/netlib/.eggs/pyOpenSSL-0.15.1-py2.7.egg
Searching for cffi
Reading https://pypi.python.org/simple/cffi/
Best match: cffi 1.1.2
Downloading https://pypi.python.org/packages/source/c/cffi/cffi-1.1.2.tar.gz#md5=ca6e6c45b45caa87aee9adc7c796eaea
Processing cffi-1.1.2.tar.gz
Writing /tmp/easy_install-_e2qwn/cffi-1.1.2/setup.cfg
Running cffi-1.1.2/setup.py -q bdist_egg --dist-dir /tmp/easy_install-_e2qwn/cffi-1.1.2/egg-dist-tmp-382ExN
c/_cffi_backend.c:13:10: fatal error: 'ffi.h' file not found
#include <ffi.h>
^
1 error generated.
Traceback (most recent call last):
File "<string>", line 20, in <module>
File "/private/tmp/pip-build-wOHXdq/netlib/setup.py", line 87, in <module>
"install": CFFIInstall,
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 112, in setup
_setup_distribution = dist = klass(attrs)
File "build/bdist.macosx-10.10-intel/egg/setuptools/dist.py", line 268, in __init__
File "build/bdist.macosx-10.10-intel/egg/setuptools/dist.py", line 313, in fetch_build_eggs
File "build/bdist.macosx-10.10-intel/egg/pkg_resources/__init__.py", line 836, in resolve
File "build/bdist.macosx-10.10-intel/egg/pkg_resources/__init__.py", line 1081, in best_match
File "build/bdist.macosx-10.10-intel/egg/pkg_resources/__init__.py", line 1093, in obtain
File "build/bdist.macosx-10.10-intel/egg/setuptools/dist.py", line 380, in fetch_build_egg
File "build/bdist.macosx-10.10-intel/egg/setuptools/command/easy_install.py", line 629, in easy_install
File "build/bdist.macosx-10.10-intel/egg/setuptools/command/easy_install.py", line 659, in install_item
File "build/bdist.macosx-10.10-intel/egg/setuptools/command/easy_install.py", line 842, in install_eggs
File "build/bdist.macosx-10.10-intel/egg/setuptools/command/easy_install.py", line 1070, in build_and_install
File "build/bdist.macosx-10.10-intel/egg/setuptools/command/easy_install.py", line 1058, in run_setup
distutils.errors.DistutilsError: Setup script exited with error: command 'cc' failed with exit status 1
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/tmp/pip-build-wOHXdq/netlib
Updated after first response for libffi:
After Installing libffi, it started breaking on libxml. I found the lxml on pip.
and its break again and looking for libxml :(
104:~ user2368563$ brew install libxml
Error: No available formula for libxml
Searching formulae...
libxml++ libxml2 libxmlsec1
Searching taps...
homebrew/versions/libxml278
104:~ user2368563$ brew install libxml2
Warning: libxml2-2.9.2 already installed
104:bin user2368563$ sudo pip install lxml
The directory '/Users/alokchoudhary/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/alokchoudhary/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting lxml
/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
Downloading lxml-3.4.4.tar.gz (3.5MB)
100% |████████████████████████████████| 3.5MB 116kB/s
Installing collected packages: lxml
Running setup.py install for lxml
Complete output from command /usr/bin/python -c "import setuptools, tokenize;__file__='/private/tmp/pip-build-bDtXaT/lxml/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-gmvCN9-record/install-record.txt --single-version-externally-managed --compile:
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url'
warnings.warn(msg)
Building lxml version 3.4.4.
Building without Cython.
Using build configuration of libxslt 1.1.28
running install
running build
running build_py
creating build
creating build/lib.macosx-10.10-intel-2.7
creating build/lib.macosx-10.10-intel-2.7/lxml
copying src/lxml/__init__.py -> build/lib.macosx-10.10-intel-2.7/lxml
copying src/lxml/_elementpath.py -> build/lib.macosx-10.10-intel-2.7/lxml
copying src/lxml/builder.py -> build/lib.macosx-10.10-intel-2.7/lxml
copying src/lxml/cssselect.py -> build/lib.macosx-10.10-intel-2.7/lxml
copying src/lxml/doctestcompare.py -> build/lib.macosx-10.10-intel-2.7/lxml
copying src/lxml/ElementInclude.py -> build/lib.macosx-10.10-intel-2.7/lxml
copying src/lxml/pyclasslookup.py -> build/lib.macosx-10.10-intel-2.7/lxml
copying src/lxml/sax.py -> build/lib.macosx-10.10-intel-2.7/lxml
copying src/lxml/usedoctest.py -> build/lib.macosx-10.10-intel-2.7/lxml
creating build/lib.macosx-10.10-intel-2.7/lxml/includes
copying src/lxml/includes/__init__.py -> build/lib.macosx-10.10-intel-2.7/lxml/includes
creating build/lib.macosx-10.10-intel-2.7/lxml/html
copying src/lxml/html/__init__.py -> build/lib.macosx-10.10-intel-2.7/lxml/html
copying src/lxml/html/_diffcommand.py -> build/lib.macosx-10.10-intel-2.7/lxml/html
copying src/lxml/html/_html5builder.py -> build/lib.macosx-10.10-intel-2.7/lxml/html
copying src/lxml/html/_setmixin.py -> build/lib.macosx-10.10-intel-2.7/lxml/html
copying src/lxml/html/builder.py -> build/lib.macosx-10.10-intel-2.7/lxml/html
copying src/lxml/html/clean.py -> build/lib.macosx-10.10-intel-2.7/lxml/html
copying src/lxml/html/defs.py -> build/lib.macosx-10.10-intel-2.7/lxml/html
copying src/lxml/html/diff.py -> build/lib.macosx-10.10-intel-2.7/lxml/html
copying src/lxml/html/ElementSoup.py -> build/lib.macosx-10.10-intel-2.7/lxml/html
copying src/lxml/html/formfill.py -> build/lib.macosx-10.10-intel-2.7/lxml/html
copying src/lxml/html/html5parser.py -> build/lib.macosx-10.10-intel-2.7/lxml/html
copying src/lxml/html/soupparser.py -> build/lib.macosx-10.10-intel-2.7/lxml/html
copying src/lxml/html/usedoctest.py -> build/lib.macosx-10.10-intel-2.7/lxml/html
creating build/lib.macosx-10.10-intel-2.7/lxml/isoschematron
copying src/lxml/isoschematron/__init__.py -> build/lib.macosx-10.10-intel-2.7/lxml/isoschematron
copying src/lxml/lxml.etree.h -> build/lib.macosx-10.10-intel-2.7/lxml
copying src/lxml/lxml.etree_api.h -> build/lib.macosx-10.10-intel-2.7/lxml
copying src/lxml/includes/c14n.pxd -> build/lib.macosx-10.10-intel-2.7/lxml/includes
copying src/lxml/includes/config.pxd -> build/lib.macosx-10.10-intel-2.7/lxml/includes
copying src/lxml/includes/dtdvalid.pxd -> build/lib.macosx-10.10-intel-2.7/lxml/includes
copying src/lxml/includes/etreepublic.pxd -> build/lib.macosx-10.10-intel-2.7/lxml/includes
copying src/lxml/includes/htmlparser.pxd -> build/lib.macosx-10.10-intel-2.7/lxml/includes
copying src/lxml/includes/relaxng.pxd -> build/lib.macosx-10.10-intel-2.7/lxml/includes
copying src/lxml/includes/schematron.pxd -> build/lib.macosx-10.10-intel-2.7/lxml/includes
copying src/lxml/includes/tree.pxd -> build/lib.macosx-10.10-intel-2.7/lxml/includes
copying src/lxml/includes/uri.pxd -> build/lib.macosx-10.10-intel-2.7/lxml/includes
copying src/lxml/includes/xinclude.pxd -> build/lib.macosx-10.10-intel-2.7/lxml/includes
copying src/lxml/includes/xmlerror.pxd -> build/lib.macosx-10.10-intel-2.7/lxml/includes
copying src/lxml/includes/xmlparser.pxd -> build/lib.macosx-10.10-intel-2.7/lxml/includes
copying src/lxml/includes/xmlschema.pxd -> build/lib.macosx-10.10-intel-2.7/lxml/includes
copying src/lxml/includes/xpath.pxd -> build/lib.macosx-10.10-intel-2.7/lxml/includes
copying src/lxml/includes/xslt.pxd -> build/lib.macosx-10.10-intel-2.7/lxml/includes
copying src/lxml/includes/etree_defs.h -> build/lib.macosx-10.10-intel-2.7/lxml/includes
copying src/lxml/includes/lxml-version.h -> build/lib.macosx-10.10-intel-2.7/lxml/includes
creating build/lib.macosx-10.10-intel-2.7/lxml/isoschematron/resources
creating build/lib.macosx-10.10-intel-2.7/lxml/isoschematron/resources/rng
copying src/lxml/isoschematron/resources/rng/iso-schematron.rng -> build/lib.macosx-10.10-intel-2.7/lxml/isoschematron/resources/rng
creating build/lib.macosx-10.10-intel-2.7/lxml/isoschematron/resources/xsl
copying src/lxml/isoschematron/resources/xsl/RNG2Schtrn.xsl -> build/lib.macosx-10.10-intel-2.7/lxml/isoschematron/resources/xsl
copying src/lxml/isoschematron/resources/xsl/XSD2Schtrn.xsl -> build/lib.macosx-10.10-intel-2.7/lxml/isoschematron/resources/xsl
creating build/lib.macosx-10.10-intel-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_abstract_expand.xsl -> build/lib.macosx-10.10-intel-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_dsdl_include.xsl -> build/lib.macosx-10.10-intel-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_schematron_message.xsl -> build/lib.macosx-10.10-intel-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_schematron_skeleton_for_xslt1.xsl -> build/lib.macosx-10.10-intel-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_svrl_for_xslt1.xsl -> build/lib.macosx-10.10-intel-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/readme.txt -> build/lib.macosx-10.10-intel-2.7/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
running build_ext
building 'lxml.etree' extension
creating build/temp.macosx-10.10-intel-2.7
creating build/temp.macosx-10.10-intel-2.7/src
creating build/temp.macosx-10.10-intel-2.7/src/lxml
cc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -arch i386 -pipe -I/usr/include/libxml2 -I/private/tmp/pip-build-bDtXaT/lxml/src/lxml/includes -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/lxml/lxml.etree.c -o build/temp.macosx-10.10-intel-2.7/src/lxml/lxml.etree.o -w -flat_namespace
In file included from src/lxml/lxml.etree.c:239:
/private/tmp/pip-build-bDtXaT/lxml/src/lxml/includes/etree_defs.h:14:10: fatal error: 'libxml/xmlversion.h' file not found
#include "libxml/xmlversion.h"
^
1 error generated.
error: command 'cc' failed with exit status 1
----------------------------------------
Command "/usr/bin/python -c "import setuptools, tokenize;__file__='/private/tmp/pip-build-bDtXaT/lxml/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-gmvCN9-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/tmp/pip-build-bDtXaT/lxml
If you read through your log carefully you might spot this line:
c/_cffi_backend.c:13:10: fatal error: 'ffi.h' file not found
The "fatal error" part is especially important. :)
This means that the ffi headers couldn't be located by your compiler. I'm not sure how to do it since I'm not a Mac user but maybe homebrew could help you, or Google. To me it seems like you should install homebrew and then just run:
brew install libffi
Then try pip again.
Edit
The full list of dependencies are:
python
libffi
libssl
libxml2
libxslt1
So you'll need all those, and their headers, if you want to continue down this path.
An easier solution is to download pre-built binaries for your Mac, from mitmproxy.org (OSX Mountain Lion and later). I found this info in the installation docs.
I was installing h5py on an Ubuntu server. However it seems to return an error that h5py.h is not found. It gives the same error message when I install it using pip or the setup.py file. What am I missing here?
I have Numpy version 1.8.1, which higher than the required version of 1.6 or above.
The complete output is as follows:
van#Hulk:~/h5py-2.3.1⟫ sudo python setup.py install
libhdf5.so: cannot open shared object file: No such file or directory
HDF5 autodetection failed; building for 1.8.4+
running install
running bdist_egg
running egg_info
writing h5py.egg-info/PKG-INFO
writing top-level names to h5py.egg-info/top_level.txt
writing dependency_links to h5py.egg-info/dependency_links.txt
reading manifest file 'h5py.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching '*.c' under directory 'win_include'
warning: no files found matching '*.h' under directory 'win_include'
writing manifest file 'h5py.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
creating build
creating build/lib.linux-x86_64-2.7
creating build/lib.linux-x86_64-2.7/h5py
copying h5py/ipy_completer.py -> build/lib.linux-x86_64-2.7/h5py
copying h5py/__init__.py -> build/lib.linux-x86_64-2.7/h5py
copying h5py/version.py -> build/lib.linux-x86_64-2.7/h5py
copying h5py/highlevel.py -> build/lib.linux-x86_64-2.7/h5py
creating build/lib.linux-x86_64-2.7/h5py/_hl
copying h5py/_hl/group.py -> build/lib.linux-x86_64-2.7/h5py/_hl
copying h5py/_hl/files.py -> build/lib.linux-x86_64-2.7/h5py/_hl
copying h5py/_hl/selections.py -> build/lib.linux-x86_64-2.7/h5py/_hl
copying h5py/_hl/__init__.py -> build/lib.linux-x86_64-2.7/h5py/_hl
copying h5py/_hl/filters.py -> build/lib.linux-x86_64-2.7/h5py/_hl
copying h5py/_hl/base.py -> build/lib.linux-x86_64-2.7/h5py/_hl
copying h5py/_hl/dims.py -> build/lib.linux-x86_64-2.7/h5py/_hl
copying h5py/_hl/datatype.py -> build/lib.linux-x86_64-2.7/h5py/_hl
copying h5py/_hl/dataset.py -> build/lib.linux-x86_64-2.7/h5py/_hl
copying h5py/_hl/selections2.py -> build/lib.linux-x86_64-2.7/h5py/_hl
copying h5py/_hl/attrs.py -> build/lib.linux-x86_64-2.7/h5py/_hl
creating build/lib.linux-x86_64-2.7/h5py/tests
copying h5py/tests/test_selections.py -> build/lib.linux-x86_64-2.7/h5py/tests
copying h5py/tests/test_group.py -> build/lib.linux-x86_64-2.7/h5py/tests
copying h5py/tests/test_h5.py -> build/lib.linux-x86_64-2.7/h5py/tests
copying h5py/tests/test_attrs.py -> build/lib.linux-x86_64-2.7/h5py/tests
copying h5py/tests/test_objects.py -> build/lib.linux-x86_64-2.7/h5py/tests
copying h5py/tests/test_slicing.py -> build/lib.linux-x86_64-2.7/h5py/tests
copying h5py/tests/test_h5t.py -> build/lib.linux-x86_64-2.7/h5py/tests
copying h5py/tests/test_datatype.py -> build/lib.linux-x86_64-2.7/h5py/tests
copying h5py/tests/__init__.py -> build/lib.linux-x86_64-2.7/h5py/tests
copying h5py/tests/test_dimension_scales.py -> build/lib.linux-x86_64-2.7/h5py/tests
copying h5py/tests/test_base.py -> build/lib.linux-x86_64-2.7/h5py/tests
copying h5py/tests/test_dataset.py -> build/lib.linux-x86_64-2.7/h5py/tests
copying h5py/tests/test_file.py -> build/lib.linux-x86_64-2.7/h5py/tests
copying h5py/tests/test_h5p.py -> build/lib.linux-x86_64-2.7/h5py/tests
copying h5py/tests/test_attrs_data.py -> build/lib.linux-x86_64-2.7/h5py/tests
copying h5py/tests/common.py -> build/lib.linux-x86_64-2.7/h5py/tests
copying h5py/tests/test_h5f.py -> build/lib.linux-x86_64-2.7/h5py/tests
running build_ext
skipping 'h5py/defs.c' Cython extension (up-to-date)
building 'h5py.defs' extension
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/h5py
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DH5_USE_16_API -I/home/govinda/h5py-2.3.1/lzf -I/usr/lib/python2.7/dist-packages/numpy/core/include -I/usr/include/python2.7 -c h5py/defs.c -o build/temp.linux-x86_64-2.7/h5py/defs.o
In file included from /usr/lib/python2.7/dist-packages/numpy/core/include/numpy/ndarraytypes.h:1761:0,
from /usr/lib/python2.7/dist-packages/numpy/core/include/numpy/ndarrayobject.h:17,
from /usr/lib/python2.7/dist-packages/numpy/core/include/numpy/arrayobject.h:4,
from h5py/api_compat.h:26,
from h5py/defs.c:342:
/usr/lib/python2.7/dist-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:15:2: warning: #warning "Using deprecated NumPy API, disable it by " "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
#warning "Using deprecated NumPy API, disable it by " \
^
In file included from h5py/defs.c:342:0:
h5py/api_compat.h:27:18: fatal error: hdf5.h: No such file or directory
#include "hdf5.h"
^
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
You need to install libhdf5-dev to get the required header files. Just run
sudo apt-get install libhdf5-dev
and it should install it and its dependencies automatically.
Don't worry about the NumPy warning, it just means that the package developers are using an old version of the API, but everything will still work.
You can use python-h5py.
sudo apt-get install python-h5py
And then in your Python file try:
import h5py
In my case (Ubuntu 15.04) installing libhdf5-dev was not enough.
I had to run:
HDF5_DIR=/usr/lib/x86_64-linux-gnu/hdf5/serial/ pip install h5py
to make it work.
It is generally preferable to use pip instead of installing it manually, since pip will also install all python dependencies. You would still need your header files though.
so:
sudo apt-get install libhdf5-dev
pip install h5py
I had to install both libhdf5-dev and cython3 (Ubuntu 18.04 on arm64 device, Python 3.5).
sudo apt install libhdf5-dev
sudo apt install cython3
I had the vcvarsall.bat problem, so I followed the directions here How to use MinGW's gcc compiler when installing Python package using Pip? .
Now, when using pip install lxml with Python 3.2.2 on Windows 7 I get the following error:
C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Python32\include -IC:\Pytho
n32\PC -c src/lxml/lxml.etree.c -o build\temp.win32-3.2\Release\src\lxml\lxml.et
ree.o -w
cc1.exe: error: unrecognized command line option '-mno-cygwin'
error: command 'gcc' failed with exit status 1
The entire output:
C:\Python32\Scripts>pip-3.2.exe install lxml
Downloading/unpacking lxml
Real name of requirement lxml is lxml
Downloading lxml-2.3.3.tar.gz (3.1Mb): 3.1Mb downloaded
Running setup.py egg_info for package lxml
Building lxml version 2.3.3.
Building without Cython.
ERROR: b"'xslt-config' is not recognized as an internal or external command,
\r\noperable program or batch file.\r\n"
** make sure the development packages of libxml2 and libxslt are installed *
*
Using build configuration of libxslt
warning: no files found matching 'lxml.etree.c' under directory 'src\lxml'
warning: no files found matching 'lxml.objectify.c' under directory 'src\lxm
l'
warning: no files found matching 'lxml.etree.h' under directory 'src\lxml'
warning: no files found matching 'lxml.etree_api.h' under directory 'src\lxm
l'
warning: no files found matching 'etree_defs.h' under directory 'src\lxml'
warning: no files found matching 'pubkey.asc' under directory 'doc'
warning: no files found matching 'tagpython*.png' under directory 'doc'
warning: no files found matching 'Makefile' under directory 'doc'
Installing collected packages: lxml
Running setup.py install for lxml
Building lxml version 2.3.3.
Building without Cython.
ERROR: b"'xslt-config' is not recognized as an internal or external command,
\r\noperable program or batch file.\r\n"
** make sure the development packages of libxml2 and libxslt are installed *
*
Using build configuration of libxslt
building 'lxml.etree' extension
C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Python32\include -IC:\P
ython32\PC -c src/lxml/lxml.etree.c -o build\temp.win32-3.2\Release\src\lxml\lxm
l.etree.o -w
cc1.exe: error: unrecognized command line option '-mno-cygwin'
error: command 'gcc' failed with exit status 1
Complete output from command C:\Python32\python.exe -c "import setuptools;__
file__='C:\\Python32\\Scripts\\build\\lxml\\setup.py';exec(compile(open(__file__
).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-ext
ernally-managed --record c:\windows\temp\pip-w4t58y-record\install-record.txt:
Building lxml version 2.3.3.
Building without Cython.
ERROR: b"'xslt-config' is not recognized as an internal or external command,\r\n
operable program or batch file.\r\n"
** make sure the development packages of libxml2 and libxslt are installed **
Using build configuration of libxslt
running install
running build
running build_py
creating build
creating build\lib.win32-3.2
creating build\lib.win32-3.2\lxml
copying src\lxml\builder.py -> build\lib.win32-3.2\lxml
copying src\lxml\cssselect.py -> build\lib.win32-3.2\lxml
copying src\lxml\doctestcompare.py -> build\lib.win32-3.2\lxml
copying src\lxml\ElementInclude.py -> build\lib.win32-3.2\lxml
copying src\lxml\pyclasslookup.py -> build\lib.win32-3.2\lxml
copying src\lxml\sax.py -> build\lib.win32-3.2\lxml
copying src\lxml\usedoctest.py -> build\lib.win32-3.2\lxml
copying src\lxml\_elementpath.py -> build\lib.win32-3.2\lxml
copying src\lxml\__init__.py -> build\lib.win32-3.2\lxml
creating build\lib.win32-3.2\lxml\html
copying src\lxml\html\builder.py -> build\lib.win32-3.2\lxml\html
copying src\lxml\html\clean.py -> build\lib.win32-3.2\lxml\html
copying src\lxml\html\defs.py -> build\lib.win32-3.2\lxml\html
copying src\lxml\html\diff.py -> build\lib.win32-3.2\lxml\html
copying src\lxml\html\ElementSoup.py -> build\lib.win32-3.2\lxml\html
copying src\lxml\html\formfill.py -> build\lib.win32-3.2\lxml\html
copying src\lxml\html\html5parser.py -> build\lib.win32-3.2\lxml\html
copying src\lxml\html\soupparser.py -> build\lib.win32-3.2\lxml\html
copying src\lxml\html\usedoctest.py -> build\lib.win32-3.2\lxml\html
copying src\lxml\html\_dictmixin.py -> build\lib.win32-3.2\lxml\html
copying src\lxml\html\_diffcommand.py -> build\lib.win32-3.2\lxml\html
copying src\lxml\html\_html5builder.py -> build\lib.win32-3.2\lxml\html
copying src\lxml\html\_setmixin.py -> build\lib.win32-3.2\lxml\html
copying src\lxml\html\__init__.py -> build\lib.win32-3.2\lxml\html
creating build\lib.win32-3.2\lxml\isoschematron
copying src\lxml\isoschematron\__init__.py -> build\lib.win32-3.2\lxml\isoschema
tron
copying src\lxml\etreepublic.pxd -> build\lib.win32-3.2\lxml
copying src\lxml\tree.pxd -> build\lib.win32-3.2\lxml
copying src\lxml\etree_defs.h -> build\lib.win32-3.2\lxml
creating build\lib.win32-3.2\lxml\isoschematron\resources
creating build\lib.win32-3.2\lxml\isoschematron\resources\rng
copying src\lxml\isoschematron\resources\rng\iso-schematron.rng -> build\lib.win
32-3.2\lxml\isoschematron\resources\rng
creating build\lib.win32-3.2\lxml\isoschematron\resources\xsl
copying src\lxml\isoschematron\resources\xsl\RNG2Schtrn.xsl -> build\lib.win32-3
.2\lxml\isoschematron\resources\xsl
copying src\lxml\isoschematron\resources\xsl\XSD2Schtrn.xsl -> build\lib.win32-3
.2\lxml\isoschematron\resources\xsl
creating build\lib.win32-3.2\lxml\isoschematron\resources\xsl\iso-schematron-xsl
t1
copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\iso_abstract_e
xpand.xsl -> build\lib.win32-3.2\lxml\isoschematron\resources\xsl\iso-schematron
-xslt1
copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\iso_dsdl_inclu
de.xsl -> build\lib.win32-3.2\lxml\isoschematron\resources\xsl\iso-schematron-xs
lt1
copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\iso_schematron
_message.xsl -> build\lib.win32-3.2\lxml\isoschematron\resources\xsl\iso-schemat
ron-xslt1
copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\iso_schematron
_skeleton_for_xslt1.xsl -> build\lib.win32-3.2\lxml\isoschematron\resources\xsl\
iso-schematron-xslt1
copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\iso_svrl_for_x
slt1.xsl -> build\lib.win32-3.2\lxml\isoschematron\resources\xsl\iso-schematron-
xslt1
copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\readme.txt ->
build\lib.win32-3.2\lxml\isoschematron\resources\xsl\iso-schematron-xslt1
running build_ext
building 'lxml.etree' extension
creating build\temp.win32-3.2
creating build\temp.win32-3.2\Release
creating build\temp.win32-3.2\Release\src
creating build\temp.win32-3.2\Release\src\lxml
C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Python32\include -IC:\Pytho
n32\PC -c src/lxml/lxml.etree.c -o build\temp.win32-3.2\Release\src\lxml\lxml.et
ree.o -w
cc1.exe: error: unrecognized command line option '-mno-cygwin'
error: command 'gcc' failed with exit status 1
----------------------------------------
Command C:\Python32\python.exe -c "import setuptools;__file__='C:\\Python32\\Scr
ipts\\build\\lxml\\setup.py';exec(compile(open(__file__).read().replace('\r\n',
'\n'), __file__, 'exec'))" install --single-version-externally-managed --record
c:\windows\temp\pip-w4t58y-record\install-record.txt failed with error code 1
Storing complete log in C:\Users\x\AppData\Roaming\pip\pip.log
The same thing happens with easy_install, but it doesn't happen when I install a package like 'bible'.
It is a known issue with distutils: mingw & -mno-cygwin with recent gcc.
See related SO question: Compiling with cython and mingw produces gcc: error: unrecognized command line option '-mno-cygwin'.
Try to remove -mno-cygwin from Mingw32CCompiler.
I downloaded the tar.gz file from http://sourceforge.net/projects/mysql-python/files/
unzip, then ran python setup.py install, but it said it requires setuptools module, so I downloaded setuptools from http://pypi.python.org/pypi/setuptools#files The file was setuptools-0.6c11-py2.7.egg (md5) then I ran
sh setuptools-0.6c9-py2.4.egg
Then back to mysql-python-1.2.3 folder, I ran
sudo setup.py install
Just for the record, here is the installation log:
MacBook-Pros-MacBook-Pro:MySQL-python-1.2.3 2 macbookpro$ python setup.py install
running install
running bdist_egg
running egg_info
writing MySQL_python.egg-info/PKG-INFO
writing top-level names to MySQL_python.egg-info/top_level.txt
writing dependency_links to MySQL_python.egg-info/dependency_links.txt
reading manifest file 'MySQL_python.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching 'MANIFEST'
warning: no files found matching 'ChangeLog'
warning: no files found matching 'GPL'
writing manifest file 'MySQL_python.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.3-fat/egg
running install_lib
running build_py
creating build
creating build/lib.macosx-10.3-fat-2.7
copying _mysql_exceptions.py -> build/lib.macosx-10.3-fat-2.7
creating build/lib.macosx-10.3-fat-2.7/MySQLdb
copying MySQLdb/__init__.py -> build/lib.macosx-10.3-fat-2.7/MySQLdb
copying MySQLdb/converters.py -> build/lib.macosx-10.3-fat-2.7/MySQLdb
copying MySQLdb/connections.py -> build/lib.macosx-10.3-fat-2.7/MySQLdb
copying MySQLdb/cursors.py -> build/lib.macosx-10.3-fat-2.7/MySQLdb
copying MySQLdb/release.py -> build/lib.macosx-10.3-fat-2.7/MySQLdb
copying MySQLdb/times.py -> build/lib.macosx-10.3-fat-2.7/MySQLdb
creating build/lib.macosx-10.3-fat-2.7/MySQLdb/constants
copying MySQLdb/constants/__init__.py -> build/lib.macosx-10.3-fat-2.7/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.macosx-10.3-fat-2.7/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.3-fat-2.7/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.macosx-10.3-fat-2.7/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.3-fat-2.7/MySQLdb/constants
copying MySQLdb/constants/REFRESH.py -> build/lib.macosx-10.3-fat-2.7/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.3-fat-2.7/MySQLdb/constants
running build_ext
building '_mysql' extension
creating build/temp.macosx-10.3-fat-2.7
gcc-4.0 -fno-strict-aliasing -fno-common -dynamic -isysroot /Developer/SDKs/MacOSX10.4u.sdk -g -O2 -DNDEBUG -g -O3 -Dversion_info=(1,2,3,'final',0) -D__version__=1.2.3 -I/usr/local/mysql/include -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _mysql.c -o build/temp.macosx-10.3-fat-2.7/_mysql.o -g -Os -arch x86_64 -fno-common -D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -DIGNORE_SIGHUP_SIGQUIT -DDONT_DECLARE_CXA_PURE_VIRTUAL
In file included from _mysql.c:36:
/usr/local/mysql/include/my_config.h:1069:1: warning: "HAVE_WCSCOLL" redefined
In file included from /Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:8,
from pymemcompat.h:10,
from _mysql.c:29:
/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/pyconfig.h:881:1: warning: this is the location of the previous definition
gcc-4.0 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -isysroot /Developer/SDKs/MacOSX10.4u.sdk -g -bundle -undefined dynamic_lookup build/temp.macosx-10.3-fat-2.7/_mysql.o -L/usr/local/mysql/lib -lmysqlclient_r -lz -lm -lmygcc -o build/lib.macosx-10.3-fat-2.7/_mysql.so -arch x86_64
creating build/bdist.macosx-10.3-fat
creating build/bdist.macosx-10.3-fat/egg
copying build/lib.macosx-10.3-fat-2.7/_mysql.so -> build/bdist.macosx-10.3-fat/egg
copying build/lib.macosx-10.3-fat-2.7/_mysql_exceptions.py -> build/bdist.macosx-10.3-fat/egg
creating build/bdist.macosx-10.3-fat/egg/MySQLdb
copying build/lib.macosx-10.3-fat-2.7/MySQLdb/__init__.py -> build/bdist.macosx-10.3-fat/egg/MySQLdb
copying build/lib.macosx-10.3-fat-2.7/MySQLdb/connections.py -> build/bdist.macosx-10.3-fat/egg/MySQLdb
creating build/bdist.macosx-10.3-fat/egg/MySQLdb/constants
copying build/lib.macosx-10.3-fat-2.7/MySQLdb/constants/__init__.py -> build/bdist.macosx-10.3-fat/egg/MySQLdb/constants
copying build/lib.macosx-10.3-fat-2.7/MySQLdb/constants/CLIENT.py -> build/bdist.macosx-10.3-fat/egg/MySQLdb/constants
copying build/lib.macosx-10.3-fat-2.7/MySQLdb/constants/CR.py -> build/bdist.macosx-10.3-fat/egg/MySQLdb/constants
copying build/lib.macosx-10.3-fat-2.7/MySQLdb/constants/ER.py -> build/bdist.macosx-10.3-fat/egg/MySQLdb/constants
copying build/lib.macosx-10.3-fat-2.7/MySQLdb/constants/FIELD_TYPE.py -> build/bdist.macosx-10.3-fat/egg/MySQLdb/constants
copying build/lib.macosx-10.3-fat-2.7/MySQLdb/constants/FLAG.py -> build/bdist.macosx-10.3-fat/egg/MySQLdb/constants
copying build/lib.macosx-10.3-fat-2.7/MySQLdb/constants/REFRESH.py -> build/bdist.macosx-10.3-fat/egg/MySQLdb/constants
copying build/lib.macosx-10.3-fat-2.7/MySQLdb/converters.py -> build/bdist.macosx-10.3-fat/egg/MySQLdb
copying build/lib.macosx-10.3-fat-2.7/MySQLdb/cursors.py -> build/bdist.macosx-10.3-fat/egg/MySQLdb
copying build/lib.macosx-10.3-fat-2.7/MySQLdb/release.py -> build/bdist.macosx-10.3-fat/egg/MySQLdb
copying build/lib.macosx-10.3-fat-2.7/MySQLdb/times.py -> build/bdist.macosx-10.3-fat/egg/MySQLdb
byte-compiling build/bdist.macosx-10.3-fat/egg/_mysql_exceptions.py to _mysql_exceptions.pyc
byte-compiling build/bdist.macosx-10.3-fat/egg/MySQLdb/__init__.py to __init__.pyc
byte-compiling build/bdist.macosx-10.3-fat/egg/MySQLdb/connections.py to connections.pyc
byte-compiling build/bdist.macosx-10.3-fat/egg/MySQLdb/constants/__init__.py to __init__.pyc
byte-compiling build/bdist.macosx-10.3-fat/egg/MySQLdb/constants/CLIENT.py to CLIENT.pyc
byte-compiling build/bdist.macosx-10.3-fat/egg/MySQLdb/constants/CR.py to CR.pyc
byte-compiling build/bdist.macosx-10.3-fat/egg/MySQLdb/constants/ER.py to ER.pyc
byte-compiling build/bdist.macosx-10.3-fat/egg/MySQLdb/constants/FIELD_TYPE.py to FIELD_TYPE.pyc
byte-compiling build/bdist.macosx-10.3-fat/egg/MySQLdb/constants/FLAG.py to FLAG.pyc
byte-compiling build/bdist.macosx-10.3-fat/egg/MySQLdb/constants/REFRESH.py to REFRESH.pyc
byte-compiling build/bdist.macosx-10.3-fat/egg/MySQLdb/converters.py to converters.pyc
byte-compiling build/bdist.macosx-10.3-fat/egg/MySQLdb/cursors.py to cursors.pyc
byte-compiling build/bdist.macosx-10.3-fat/egg/MySQLdb/release.py to release.pyc
byte-compiling build/bdist.macosx-10.3-fat/egg/MySQLdb/times.py to times.pyc
creating stub loader for _mysql.so
byte-compiling build/bdist.macosx-10.3-fat/egg/_mysql.py to _mysql.pyc
creating build/bdist.macosx-10.3-fat/egg/EGG-INFO
copying MySQL_python.egg-info/PKG-INFO -> build/bdist.macosx-10.3-fat/egg/EGG-INFO
copying MySQL_python.egg-info/SOURCES.txt -> build/bdist.macosx-10.3-fat/egg/EGG-INFO
copying MySQL_python.egg-info/dependency_links.txt -> build/bdist.macosx-10.3-fat/egg/EGG-INFO
copying MySQL_python.egg-info/top_level.txt -> build/bdist.macosx-10.3-fat/egg/EGG-INFO
writing build/bdist.macosx-10.3-fat/egg/EGG-INFO/native_libs.txt
zip_safe flag not set; analyzing archive contents...
creating dist
creating 'dist/MySQL_python-1.2.3-py2.7-macosx-10.3-fat.egg' and adding 'build/bdist.macosx-10.3-fat/egg' to it
removing 'build/bdist.macosx-10.3-fat/egg' (and everything under it)
Processing MySQL_python-1.2.3-py2.7-macosx-10.3-fat.egg
Copying MySQL_python-1.2.3-py2.7-macosx-10.3-fat.egg to /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
Adding MySQL-python 1.2.3 to easy-install.pth file
Installed /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/MySQL_python-1.2.3-py2.7-macosx-10.3-fat.egg
Processing dependencies for MySQL-python==1.2.3
Finished processing dependencies for MySQL-python==1.2.3
Then in my Django project folder I ran python manage.py runserver
but it failed, returned this:
Validating models...
Unhandled exception in thread started by <function inner_run at 0x106df70>
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 48, in inner_run
self.validate(display_num_errors=True)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/base.py", line 249, in validate
num_errors = get_validation_errors(s, app)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/validation.py", line 22, in get_validation_errors
from django.db import models, connection
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/__init__.py", line 77, in <module>
connection = connections[DEFAULT_DB_ALIAS]
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/utils.py", line 91, in __getitem__
backend = load_backend(db['ENGINE'])
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/utils.py", line 32, in load_backend
return import_module('.base', backend_name)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 14, in <module>
raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: dlopen(/Users/macbookpro/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.3-fat.egg-tmp/_mysql.so, 2): no suitable image found. Did find:
/Users/macbookpro/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.3-fat.egg-tmp/_mysql.so: mach-o, but wrong architecture
Has anybody had similar problem before? Can anybody help, please? Thank you
Update
file /Users/macbookpro/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.3-fat.egg-tmp/_mysql.so
returned:
/Users/macbookpro/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.3-fat.egg-tmp/_mysql.so: Mach-O 64-bit bundle x86_64
and
file `which python`
returned:
/Library/Frameworks/Python.framework/Versions/2.7/bin/python: Mach-O universal binary with 2 architectures
/Library/Frameworks/Python.framework/Versions/2.7/bin/python (for architecture ppc): Mach-O executable ppc
/Library/Frameworks/Python.framework/Versions/2.7/bin/python (for architecture i386): Mach-O executable i386
Update 1
Based on the information above, I thought the error was caused by python installed in i386 while MySQLdb in x86_64 (whatever that means...) So I tried to build MySQLdb with arch i386 using technique shown in this tutorial: http://cd34.com/blog/programming/python/mysql-python-and-snow-leopard/, but it didn't work, then I tried to build it with x86_64, does not work either.
Here is my terminal history:
build with i386:
ARCHFLAGS='-arch i386' python setup.py build
returned:
running build
running build_py
creating build/lib.macosx-10.3-i386-2.7
copying _mysql_exceptions.py -> build/lib.macosx-10.3-i386-2.7
creating build/lib.macosx-10.3-i386-2.7/MySQLdb
copying MySQLdb/__init__.py -> build/lib.macosx-10.3-i386-2.7/MySQLdb
copying MySQLdb/converters.py -> build/lib.macosx-10.3-i386-2.7/MySQLdb
copying MySQLdb/connections.py -> build/lib.macosx-10.3-i386-2.7/MySQLdb
copying MySQLdb/cursors.py -> build/lib.macosx-10.3-i386-2.7/MySQLdb
copying MySQLdb/release.py -> build/lib.macosx-10.3-i386-2.7/MySQLdb
copying MySQLdb/times.py -> build/lib.macosx-10.3-i386-2.7/MySQLdb
creating build/lib.macosx-10.3-i386-2.7/MySQLdb/constants
copying MySQLdb/constants/__init__.py -> build/lib.macosx-10.3-i386-2.7/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.macosx-10.3-i386-2.7/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.3-i386-2.7/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.macosx-10.3-i386-2.7/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.3-i386-2.7/MySQLdb/constants
copying MySQLdb/constants/REFRESH.py -> build/lib.macosx-10.3-i386-2.7/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.3-i386-2.7/MySQLdb/constants
running build_ext
building '_mysql' extension
creating build/temp.macosx-10.3-i386-2.7
gcc-4.0 -fno-strict-aliasing -fno-common -dynamic -isysroot /Developer/SDKs/MacOSX10.4u.sdk -g -O2 -DNDEBUG -g -O3 -Dversion_info=(1,2,3,'final',0) -D__version__=1.2.3 -I/usr/local/mysql/include -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _mysql.c -o build/temp.macosx-10.3-i386-2.7/_mysql.o -g -Os -arch x86_64 -fno-common -D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -DIGNORE_SIGHUP_SIGQUIT -DDONT_DECLARE_CXA_PURE_VIRTUAL
In file included from _mysql.c:36:
/usr/local/mysql/include/my_config.h:1069:1: warning: "HAVE_WCSCOLL" redefined
In file included from /Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:8,
from pymemcompat.h:10,
from _mysql.c:29:
/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/pyconfig.h:881:1: warning: this is the location of the previous definition
gcc-4.0 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -isysroot /Developer/SDKs/MacOSX10.4u.sdk -g -bundle -undefined dynamic_lookup build/temp.macosx-10.3-i386-2.7/_mysql.o -L/usr/local/mysql/lib -lmysqlclient_r -lz -lm -lmygcc -o build/lib.macosx-10.3-i386-2.7/_mysql.so -arch x86_64
Then ran the setup:
ARCHFLAGS='-arch i386' python setup.py install
result:
running install
running bdist_egg
running egg_info
writing MySQL_python.egg-info/PKG-INFO
writing top-level names to MySQL_python.egg-info/top_level.txt
writing dependency_links to MySQL_python.egg-info/dependency_links.txt
reading manifest file 'MySQL_python.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching 'MANIFEST'
warning: no files found matching 'ChangeLog'
warning: no files found matching 'GPL'
writing manifest file 'MySQL_python.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.3-i386/egg
running install_lib
running build_py
copying MySQLdb/release.py -> build/lib.macosx-10.3-i386-2.7/MySQLdb
running build_ext
creating build/bdist.macosx-10.3-i386
creating build/bdist.macosx-10.3-i386/egg
copying build/lib.macosx-10.3-i386-2.7/_mysql.so -> build/bdist.macosx-10.3-i386/egg
copying build/lib.macosx-10.3-i386-2.7/_mysql_exceptions.py -> build/bdist.macosx-10.3-i386/egg
creating build/bdist.macosx-10.3-i386/egg/MySQLdb
copying build/lib.macosx-10.3-i386-2.7/MySQLdb/__init__.py -> build/bdist.macosx-10.3-i386/egg/MySQLdb
copying build/lib.macosx-10.3-i386-2.7/MySQLdb/connections.py -> build/bdist.macosx-10.3-i386/egg/MySQLdb
creating build/bdist.macosx-10.3-i386/egg/MySQLdb/constants
copying build/lib.macosx-10.3-i386-2.7/MySQLdb/constants/__init__.py -> build/bdist.macosx-10.3-i386/egg/MySQLdb/constants
copying build/lib.macosx-10.3-i386-2.7/MySQLdb/constants/CLIENT.py -> build/bdist.macosx-10.3-i386/egg/MySQLdb/constants
copying build/lib.macosx-10.3-i386-2.7/MySQLdb/constants/CR.py -> build/bdist.macosx-10.3-i386/egg/MySQLdb/constants
copying build/lib.macosx-10.3-i386-2.7/MySQLdb/constants/ER.py -> build/bdist.macosx-10.3-i386/egg/MySQLdb/constants
copying build/lib.macosx-10.3-i386-2.7/MySQLdb/constants/FIELD_TYPE.py -> build/bdist.macosx-10.3-i386/egg/MySQLdb/constants
copying build/lib.macosx-10.3-i386-2.7/MySQLdb/constants/FLAG.py -> build/bdist.macosx-10.3-i386/egg/MySQLdb/constants
copying build/lib.macosx-10.3-i386-2.7/MySQLdb/constants/REFRESH.py -> build/bdist.macosx-10.3-i386/egg/MySQLdb/constants
copying build/lib.macosx-10.3-i386-2.7/MySQLdb/converters.py -> build/bdist.macosx-10.3-i386/egg/MySQLdb
copying build/lib.macosx-10.3-i386-2.7/MySQLdb/cursors.py -> build/bdist.macosx-10.3-i386/egg/MySQLdb
copying build/lib.macosx-10.3-i386-2.7/MySQLdb/release.py -> build/bdist.macosx-10.3-i386/egg/MySQLdb
copying build/lib.macosx-10.3-i386-2.7/MySQLdb/times.py -> build/bdist.macosx-10.3-i386/egg/MySQLdb
byte-compiling build/bdist.macosx-10.3-i386/egg/_mysql_exceptions.py to _mysql_exceptions.pyc
byte-compiling build/bdist.macosx-10.3-i386/egg/MySQLdb/__init__.py to __init__.pyc
byte-compiling build/bdist.macosx-10.3-i386/egg/MySQLdb/connections.py to connections.pyc
byte-compiling build/bdist.macosx-10.3-i386/egg/MySQLdb/constants/__init__.py to __init__.pyc
byte-compiling build/bdist.macosx-10.3-i386/egg/MySQLdb/constants/CLIENT.py to CLIENT.pyc
byte-compiling build/bdist.macosx-10.3-i386/egg/MySQLdb/constants/CR.py to CR.pyc
byte-compiling build/bdist.macosx-10.3-i386/egg/MySQLdb/constants/ER.py to ER.pyc
byte-compiling build/bdist.macosx-10.3-i386/egg/MySQLdb/constants/FIELD_TYPE.py to FIELD_TYPE.pyc
byte-compiling build/bdist.macosx-10.3-i386/egg/MySQLdb/constants/FLAG.py to FLAG.pyc
byte-compiling build/bdist.macosx-10.3-i386/egg/MySQLdb/constants/REFRESH.py to REFRESH.pyc
byte-compiling build/bdist.macosx-10.3-i386/egg/MySQLdb/converters.py to converters.pyc
byte-compiling build/bdist.macosx-10.3-i386/egg/MySQLdb/cursors.py to cursors.pyc
byte-compiling build/bdist.macosx-10.3-i386/egg/MySQLdb/release.py to release.pyc
byte-compiling build/bdist.macosx-10.3-i386/egg/MySQLdb/times.py to times.pyc
creating stub loader for _mysql.so
byte-compiling build/bdist.macosx-10.3-i386/egg/_mysql.py to _mysql.pyc
creating build/bdist.macosx-10.3-i386/egg/EGG-INFO
copying MySQL_python.egg-info/PKG-INFO -> build/bdist.macosx-10.3-i386/egg/EGG-INFO
copying MySQL_python.egg-info/SOURCES.txt -> build/bdist.macosx-10.3-i386/egg/EGG-INFO
copying MySQL_python.egg-info/dependency_links.txt -> build/bdist.macosx-10.3-i386/egg/EGG-INFO
copying MySQL_python.egg-info/top_level.txt -> build/bdist.macosx-10.3-i386/egg/EGG-INFO
writing build/bdist.macosx-10.3-i386/egg/EGG-INFO/native_libs.txt
zip_safe flag not set; analyzing archive contents...
creating 'dist/MySQL_python-1.2.3-py2.7-macosx-10.3-i386.egg' and adding 'build/bdist.macosx-10.3-i386/egg' to it
removing 'build/bdist.macosx-10.3-i386/egg' (and everything under it)
Processing MySQL_python-1.2.3-py2.7-macosx-10.3-i386.egg
Copying MySQL_python-1.2.3-py2.7-macosx-10.3-i386.egg to /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
Adding MySQL-python 1.2.3 to easy-install.pth file
Installed /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/MySQL_python-1.2.3-py2.7-macosx-10.3-i386.egg
Processing dependencies for MySQL-python==1.2.3
Finished processing dependencies for MySQL-python==1.2.3
Then I ran python to check if MySQLdb installed correctly:
MacBook-Pros-MacBook-Pro:MySQL-python-1.2.3 2 macbookpro$ python
Python 2.7 (r27:82508, Jul 3 2010, 20:17:05)
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/MySQL_python-1.2.3-py2.7-macosx-10.3-i386.egg/_mysql.py:3: UserWarning: Module _mysql was already imported from /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/MySQL_python-1.2.3-py2.7-macosx-10.3-i386.egg/_mysql.pyc, but /Users/macbookpro/Downloads/MySQL-python-1.2.3 2 is being added to sys.path
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "MySQLdb/__init__.py", line 19, in <module>
import _mysql
File "build/bdist.macosx-10.3-i386/egg/_mysql.py", line 7, in <module>
File "build/bdist.macosx-10.3-i386/egg/_mysql.py", line 6, in __bootstrap__
ImportError: dlopen(/Users/macbookpro/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.3-i386.egg-tmp/_mysql.so, 2): no suitable image found. Did find:
/Users/macbookpro/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.3-i386.egg-tmp/_mysql.so: mach-o, but wrong architecture
Then since it doesn't work, I desperately tried to build it with -arch x86_64, but does not work either:
ARCHFLAGS='-arch x86_64' python setup.py build
running build
running build_py
creating build/lib.macosx-10.3-x86_64-2.7
copying _mysql_exceptions.py -> build/lib.macosx-10.3-x86_64-2.7
creating build/lib.macosx-10.3-x86_64-2.7/MySQLdb
copying MySQLdb/__init__.py -> build/lib.macosx-10.3-x86_64-2.7/MySQLdb
copying MySQLdb/converters.py -> build/lib.macosx-10.3-x86_64-2.7/MySQLdb
copying MySQLdb/connections.py -> build/lib.macosx-10.3-x86_64-2.7/MySQLdb
copying MySQLdb/cursors.py -> build/lib.macosx-10.3-x86_64-2.7/MySQLdb
copying MySQLdb/release.py -> build/lib.macosx-10.3-x86_64-2.7/MySQLdb
copying MySQLdb/times.py -> build/lib.macosx-10.3-x86_64-2.7/MySQLdb
creating build/lib.macosx-10.3-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/__init__.py -> build/lib.macosx-10.3-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.macosx-10.3-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.3-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.macosx-10.3-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.3-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/REFRESH.py -> build/lib.macosx-10.3-x86_64-2.7/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.3-x86_64-2.7/MySQLdb/constants
running build_ext
building '_mysql' extension
creating build/temp.macosx-10.3-x86_64-2.7
gcc-4.0 -fno-strict-aliasing -fno-common -dynamic -isysroot /Developer/SDKs/MacOSX10.4u.sdk -g -O2 -DNDEBUG -g -O3 -Dversion_info=(1,2,3,'final',0) -D__version__=1.2.3 -I/usr/local/mysql/include -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _mysql.c -o build/temp.macosx-10.3-x86_64-2.7/_mysql.o -g -Os -arch x86_64 -fno-common -D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -DIGNORE_SIGHUP_SIGQUIT -DDONT_DECLARE_CXA_PURE_VIRTUAL
In file included from _mysql.c:36:
/usr/local/mysql/include/my_config.h:1069:1: warning: "HAVE_WCSCOLL" redefined
In file included from /Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:8,
from pymemcompat.h:10,
from _mysql.c:29:
/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/pyconfig.h:881:1: warning: this is the location of the previous definition
gcc-4.0 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -isysroot /Developer/SDKs/MacOSX10.4u.sdk -g -bundle -undefined dynamic_lookup build/temp.macosx-10.3-x86_64-2.7/_mysql.o -L/usr/local/mysql/lib -lmysqlclient_r -lz -lm -lmygcc -o build/lib.macosx-10.3-x86_64-2.7/_mysql.so -arch x86_64
then installation
ARCHFLAGS='-arch x86_64' python setup.py install
Installed /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/MySQL_python-1.2.3-py2.7-macosx-10.3-x86_64.egg
Processing dependencies for MySQL-python==1.2.3
Finished processing dependencies for MySQL-python==1.2.3
Then again I tried to check in python
MacBook-Pros-MacBook-Pro:MySQL-python-1.2.3 2 macbookpro$ python
which failed again
>>> import MySQLdb
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/MySQL_python-1.2.3-py2.7-macosx-10.3-x86_64.egg/_mysql.py:3: UserWarning: Module _mysql was already imported from /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/MySQL_python-1.2.3-py2.7-macosx-10.3-x86_64.egg/_mysql.pyc, but /Users/macbookpro/Downloads/MySQL-python-1.2.3 2 is being added to sys.path
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "MySQLdb/__init__.py", line 19, in <module>
import _mysql
File "build/bdist.macosx-10.3-x86_64/egg/_mysql.py", line 7, in <module>
File "build/bdist.macosx-10.3-x86_64/egg/_mysql.py", line 6, in __bootstrap__
ImportError: dlopen(/Users/macbookpro/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.3-x86_64.egg-tmp/_mysql.so, 2): no suitable image found. Did find:
/Users/macbookpro/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.3-x86_64.egg-tmp/_mysql.so: mach-o, but wrong architecture
Is there anywhere I may have done wrong?
Update 2
Running this code in python (if it may help you investigating in anyway)
>>> import math
>>> import sys
>>> math.log(sys.maxint, 2)
30.999999999328196
Thank you
The root cause is probably that you have installed a 64-bit only version of the MySQL client libraries. Note that the MySQLdb build process (in setup_posix.py) queries the mysql_build command to find the various flags that were used to build the MySQL client libraries and augment the building of the MySQLdb extension module. Your Python instance and your MySQL client libraries must have at least one common architecture. Either install a version of MySQL client that includes 32-bit Intel (-arch i386) or install a 64-bit version of Python 2.7. It is for reasons like this that I recommend installing a complete Django solution (or at least a Python and MySQL solution) using MacPorts to avoid such incompatibilities.
You are probably using a 32-bit mysql with a 64-bit python (which is standard in Snow Leopard), or vice versa.
If this is not the case, then look out on the DMG MySQL came in to find the correct MySQL-python. Look here for further information.
Update
I missed something... is your Python installation 32 or 64 bit? If unsure, check with this code:
import math
import sys
math.log(sys.maxint, 2)
I fear you may have somehow missed the “matched” combination of the three programs.