您的位置:首页 > 数据库 > Oracle

Build and Install cx_Oracle on Mac Leopard Intel

2015-04-20 15:29 501 查看

Build and Install cx_Oracle on Mac Leopard Intel

I finally succeeded in building and installing cx_Oracle on a Mac. I will outline the steps that I took. There are many redundant steps that I may later take out. But there are checks that I made on the way that really helped.The first Mac that I installed cx_Oracle was a 2.4 GHz Intel Core 2 Duo running Mac OSX 10.6.6. It had 4 GB of Memory. Most of my work was done on a terminal window.

Check Python Installation

The OSX comes with a Python interpreter. I ran a check to find the version number.
$ python -V
Python 2.6.1
This was sufficient for my needs. I decided not to upgrade to Python version 2.7.1

Xcode from Apple

The Xcode package is available from Apple Developer. You will need a login account but that is free.Now you do not need Xcode 4. Xcode 3 is sufficient because all we are interested in is the gcc compiler. After you login look for a link that says Looking for Xcode 3? I downloaded X code 3.2.6 and iOS SDK 4.3. It was 4.1 GB in size and isbest done when you know you will not be using your Mac.After the download, the installation went off smoothly. I restarted the Mac and on a terminal window checked that the gcc compiler was installed correctly.
$ which gcc
/usr/bin/gcc

$ gcc -v
gcc version 4.2.1
You can also do man gcc to get the online manual for gcc.

Install Oracle Instant Client

The cx_Oracle has a dependency. It needs Oracle Instant Client from Oracle.Click on the link Instant Client for Mac OS X (Intel x86). Accept the license agreement and download Version 10.2.0.4 (64-bit). I tried the 32-bit and it does NOT work. You will need your Oracle account to download the followingpackages:instantclient-basic-10.2.0.4.0-macosx-x64.zipinstantclient-sdk-10.2.0.4.0-macosx-x64.zipI created a directory called oracle to unpack the packages. The pathname on my machine was /Users/utcs/oracle. On your machine, it will be your user name instead of utcs. I moved both the basic and sdkpackages into the oracle directory and unzipped them. After unzipping the basic package I got a folder instantclient_10_2.After unzipping the sdk package, I got a folder called instantclient_10_2-1. Inside that folder was another folder called sdk. I moved the folder named sdkinside the folder instantclient_10_2.From a terminal window I changed directory to sdk. On my machine, the full path name was /Users/utcs/oracle/instantclient_10_2/sdk. There is another .zip file called ottclasses.zip. I unzipped that asfollows:
$ unzip ottclasses.zip
It produced a folder called oracle. I changed directory to /Users/utcs/oracle/instantclient_10_2.I ran the following command to copy all the files in the sdkfolder.
$ cp -R ./sdk/* .
$ cp -R ./sdk/include/* .
The last two commands may not have been necessary. But it makes it easier to locate the header files.

Setting up the Environment Variables

In my home directory /Users/utcs I created a .profile file. Its content was as follows:
export ORACLE_HOME=/Users/utcs/oracle/instantclient_10_2
export DYLD_LIBRARY_PATH=$ORACLE_HOME
export LD_LIBRARY_PATH=$ORACLE_HOME
Restart the machine. Open another terminal window and run the following commands to check that the environment variables have been set properly:
$ source .profile
$ echo $ORACLE_HOME
$ echo $DYLD_LIBRARY_PATH
$ echo $LD_LIBRARY_PATH
You should see the path names printed out correctly. I created two symbolic links in the $ORACLE_HOME directory (/Users/utcs/oracle/instantclient_10_2) as follows:
ln -s libclntsh.dylib.10.1 libclntsh.dylib
ln -s libocci.dylib.10.1 libocci.dylib
If you run the command ls -l in that directory you should see the symbolic links.

Building and Installing cx_Oracle

Download from SourceForge cx_Oracle version 5.0.4. You need to get the package that says SourceCode only. In your Download folder you will find cx_Oracle-5.0.4.tar. I moved it to /Users/utcs/oracle. To untar, I used the following command:
tar -xvf cx_Oracle-5.0.4.tar
After untarring I had a subdirectory called cx_Oracle-5.0.4. In a terminal window I changed directory to /Users/utcs/oracle/cx_Oracle-5.0.4. I checked in that window that all the environment variables were set properlyby doing
echo $ORACLE_HOME
echo $LD_LIBRARY_PATH
echo $DYLD_LIBRARY_PATH
which python
which gcc
I did not have administrative privileges on this Mac so to build I did
python setup.py build
I checked to output. There were many warning messages that I ignored. Even a single error messagewould have indicated that the build process did not succeed. I next installed cx_Oracle by
sudo env ORACLE_HOME=/WorkSpace/oracle/instantclient11.2 pip install cx_Oracle或[code]sudo env ORACLE_HOME=/path/to/instantclient python setup.py install
[/code]
python setup.py install
The install also finished without any error messages.

Test the cx_Oracle installation

On a terminal window type python. It should bring up Python in interactive mode. Then type import cx_Oracle. It should add the package to your path without any errors. Get out of the interactive mode using Control-D.Now copy and paste this script into a file called Check.py. Change the user name and run it on the command line.
import cx_Oracle, string, getpassdef main():# Get passwordpswd = getpass.getpass()# Build connection stringuser = "CS327E_jdoe"host = "rising-sun.microlab.cs.utexas.edu"port = "1521"sid = "orcl"dsn = cx_Oracle.makedsn (host, port, sid)# Connect to Oracle and testcon = cx_Oracle.connect (user, pswd, dsn)if (con):print "Connection successful"print con.versionelse:print "Connection not successful"con.close()main()
You should see Connection successful if all the other tests were successful.cx_Oracle install on MacOSfoo.mdRawDownload Instant Client:instantclient-basic-macos.x64-11.2.0.4.0.zipinstantclient-sdk-macos.x64-11.2.0.4.0.zipinstantclient-sqlplus-macos.x64-11.2.0.4.0.zipUnzip and move to /optCreate symlink
$ cd /opt/instantclient_11_2/$ ln -s libclntsh.dylib.11.1 libclntsh.dylib
[ This step might not be needed ]Copy files:
sudo cp /opt/instantclient_11_2/sdk/include/*.h /usr/include/sudo cp /opt/instantclient_11_2/*.dylib /usr/libsudo cp /opt/instantclient_11_2/sqlplus /usr/bin
Run pip install. If it needs root permission, su to root first. Make sure you do this rather than sudo because you need to set the environment variable in the correct shell
export ORACLE_HOME=/opt/instantclient_11_2pip install cx_Oracle
Test:
Python 2.7.6 (default, Sep  9 2014, 15:04:36)[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> import cx_Oracle>>> conn_str = u'USER/PASSWORD@host.foo.com:1521/orcl'>>> conn = cx_Oracle.connect(conn_str)>>> c = conn.cursor()>>> c.execute(u'select sysdate from dual')<cx_Oracle.Cursor on <cx_Oracle.Connection to USER/PASSWORD@host.foo.com:1521/orcl>>>>> for row in c:...     print row...(datetime.datetime(2015, 2, 19, 15, 56, 5),)>>>
If you get this:
Python 2.7.6 (default, Sep  9 2014, 15:04:36)[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> import cx_OracleTraceback (most recent call last):File "<stdin>", line 1, in <module>ImportError: dlopen(/Library/Python/2.7/site-packages/cx_Oracle.so, 2): Library not loaded: /ade/b/3071542110/oracle/rdbms/lib/libclntsh.dylib.11.1Referenced from: /Library/Python/2.7/site-packages/cx_Oracle.soReason: image not found
Then make sure you've set DYLD_LIBRARY_PATH correctly:
export DYLD_LIBRARY_PATH=/opt/instantclient_11_2/

Installing cx_Oracle on a Mac

So as previously mentioned, I got a Macbook Pro. Nearly two months later, I am loving it more and more. The only gripe I had was installing a specific package called cx_Oracle; a Python Oracle DB connection package. After a lot of attempts, I finally got aworking copy installed on my local machine. I noticed there are many tutorials around the web, but they are a bit outdated, I am on Mavericks, so I will create a nice article not only for you guys, but also for myself.Necessary Downloads:cx_Oracle — Source Code Only Option — (http://cx-oracle.sourceforge.net/)Oracle Instant Client Basic 64-bit (http://www.oracle.com/technetwork/topics/intel-macsoft-096467.html)Oracle Instant Client SDK 64-bit (http://www.oracle.com/technetwork/topics/intel-macsoft-096467.html)Next Steps:Assuming you downloaded all the above files, and they are found in your Downloads directory, run the following commands assudo:
sudo su
mkdir /Users/<username_here>/oracle
mv /Users/<username_here>/Downloads/instantclient-* /Users/<username_here>/oracle
cd /Users/<username_here>/oracle
unzip instantclient-basic-macos.x64-11.2.0.3.0.zip
unzip instantclient-sdk-macos.x64-11.2.0.3.0.zip
cd instantclient_11_2/sdk
unzip ottclasses.zip
cd ..
cp -R ./sdk/* .
cp -R ./sdk/include/* .
ln -s libclntsh.dylib.11.1 libclntsh.dylib
ln -s libocci.dylib.11.1 libocci.dylib
vim ~/.bash_profile
Add the following lines (you may want to add these lines to your own accounts .bash_profile too):
export ORACLE_HOME=/Users/<username_here>/oracle/instantclient_11_2
export DYLD_LIBRARY_PATH=$ORACLE_HOME
export LD_LIBRARY_PATH=$ORACLE_HOME
Once you enter all the info, you should resource your bash_profile. After this, you setup instant client as well! I would validate all your settings are correct as well:
. ~/.bash_profile
echo $ORACLE_HOME # should be /Users/username_here/oracle/instantclient_11_2 if you followed this guide
echo $DYLD_LIBRARY_PATH # same as above
echo $LD_LIBRARY_PATH # same as above
which python # usually /usr/bin/python
which gcc # usually /usr/bin/gcc
If all of the above is set, then you are ready to proceed with the cx_Oracle Install!
. ~/.bash_profile
cd /Users/username_here/Downloads
tar -xzf cx_Oracle-5.1.2.tar.gz
cd cx_Oracle-5.1.2
sudo python setup.py build
sudo python setup.py install
If all went according to plan, it should have successfully installed! (if not post in the comments and I can help!) To test simply:
python
import cx_Oracle
# you may see some junk like:
/Library/Python/2.7/site-packages/cx_Oracle-5.1.2-py2.7-macosx-10.9-intel.egg/cx_Oracle.py:3: UserWarning: Module cx_Oracle was already imported from /Library/Python/2.7/site-packages/cx_Oracle-5.1.2-py2.7-macosx-10.9-intel.egg/cx_Oracle.pyc,but /Users/username_here/Downloads/cx_Oracle-5.1.2 is being added to sys.path
Hope this helps someone out there!UPDATE:Seems like Oracle made a change to the basic zip since this was posted, the step when you are setting up symlinks. If you used my guide previously and you did:
ln -s libclntsh.dylib.11.2 libclntsh.dylib
ln -s libocci.dylib.11.2 libocci.dylib
you should unlink your symlinks and this should be…
ln -s libclntsh.dylib.11.1 libclntsh.dylib
ln -s libocci.dylib.11.1 libocci.dylib
I have updated the article since!UPDATE 2:William Smith, a commenter on the article, said he still ran into an error where Oracle software could not be found. He was able to get past the issue by using “sudo -E” with when installing:$ sudo -E python setup.py installThe “-E” flag on sudo ensures that the local environment variables are preserved with root when the command is run. Thanks! Check out his full comment: http://joelvasallo.com/?p=276#comments Postedon December11, 2013Author jvasalloCategories Development, LinuxToMac, Tutorials

44 thoughts on “Installing cx_Oracle on a Mac”

Shishirsays:March30, 2015 at 2:22 amI was also getting error while importing the module:Traceback (most recent call last):File “”, line 1, inFile “build/bdist.macosx-10.10-intel/egg/cx_Oracle.py”, line 7, inFile “build/bdist.macosx-10.10-intel/egg/cx_Oracle.py”, line 6, in __bootstrap__ImportError: dlopen(/var/root/.python-eggs/cx_Oracle-5.2-py2.7-macosx-10.10-intel.egg-tmp/cx_Oracle.so, 2): Library not loaded: /ade/b/2649109290/oracle/rdbms/lib/libclntsh.dylib.11.1Referenced from: /var/root/.python-eggs/cx_Oracle-5.2-py2.7-macosx-10.10-intel.egg-tmp/cx_Oracle.soReason: image not found“source ~/.bash_profile” solved the problem.REPLYjvasallosays:March31, 2015 at 3:09 am. ~/.bash_profile should be the same but doesn’t hurt to reload it again. Thanks for the feedback! Glad this helped.REPLYShishirsays:March30, 2015 at 2:11 amThanks Joel. It helped. Although, I was getting:distutils.errors.DistutilsSetupError: cannot locate Oracle include filesI figured, the client sdk was missing. Downloading it and placing the include folder in $ORACLE_HOME, solved the problem.For people who are facing similar issue, SDK can be downloaded from Oracle Downloads: http://www.oracle.com/technetwork/topics/intel-macsoft-096467.htmlFile: instantclient-sdk-macos.x32-11.2.0.4.0.zipREPLYjvasallosays:March31, 2015 at 3:12 amBe careful which SDK you install. If you are running a 32bit OS, then yes it should be ok. If you are running a 64-bit you need a 64-bit SDK. I include this as one part of the steps in the tutorial.Regardless, glad you have a working setup now!REPLYKanansays:March20, 2015 at 6:39 pmThanks a lot Joel for sharing this.Those instructions made my life easy to set cx_Oracle up seamlessly.REPLYKanansays:March20, 2015 at 7:50 pmHi Joel,I guess i was in bit hurry to express my happiness.after installations when I am trying to import cx_Oracle, it’s throwing error below :kanan01:~ kanan$ pythonPython 2.7.6 (default, Sep 9 2014, 15:04:36)[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwinType “help”, “copyright”, “credits” or “license” for more information.>>> import cx_OracleTraceback (most recent call last):File “”, line 1, inFile “build/bdist.macosx-10.10-intel/egg/cx_Oracle.py”, line 7, inFile “build/bdist.macosx-10.10-intel/egg/cx_Oracle.py”, line 6, in __bootstrap__ImportError: dlopen(/Users/kanan/.python-eggs/cx_Oracle-5.1.2-py2.7-macosx-10.10-intel.egg-tmp/cx_Oracle.so,2):Library not loaded: /ade/b/3071542110/oracle/rdbms/lib/libclntsh.dylib.11.1Referenced from: /Users/kanan/.python-eggs/cx_Oracle-5.1.2-py2.7-macosx-10.10-intel.egg-tmp/cx_Oracle.soReason: image not foundI am new to python and Mac environment and not sure what went wrong .export ORACLE_HOME=/Users/kanan/oracle/instantclient_11_2export DYLD_LIBRARY_PATH=$ORACLE_HOMEexport LD_LIBRARY_PATH=$ORACLE_HOMECan you please help me understanding the root cause of this error.REPLYjvasallosays:March21, 2015 at 11:42 amHey so the build/install step worked fine?REPLYKanansays:March22, 2015 at 7:25 pmHi Joel,Thanks for replying to the post.Install part went well but while running build I got this warning:-ld: warning: ignoring file /Users/kanan/oracle/instantclient_11_2/libclntsh.dylib, file was built for x86_64 which is not the architecture being linked (i386): /Users/kanan/oracle/instantclient_11_2/libclntsh.dyliblibclntsh.dylib -> libclntsh.dylib.11.1libocci.dylib -> libocci.dylib.11.1REPLYjvasallosays:March31, 2015 at 3:14 amWhat are you running; 32bit or 64bit? The above guide is for 64-bit OS. The error above (is not the architecture being linked (i386)) refers that you are running a 32-bit OS!REPLYWilliamSmithsays:February15, 2015 at 12:42 pmThanks for posting this. I just installed cx_Oracle on a new Mac with Yosemite and ran into the “cannot locate an Oracle software” issue. I was able to get past the issue by using “sudo -E” with when installing:$ sudo -E python setup.py installThe “-E” flag on sudo ensures that the local environment variables are preserved with root when the command is run.Also, I installed the sqlplus instant client libraries, and added the environment variable TNS_ADMIN=${ORACLE_HOME} to .bash_profile. TNS_ADMIN tells SQLPLUS where to look for a tnsnames.ora file.After creating a tnsname.ora file in the $ORACLE_HOME directory, it was handy to use SQLPLUS to test connectivity to Oracle before testing it in Python with cx_Oracle. Once in Python, I used the following simple test to make sure cx_Oracle was working>>> import cx_Oracle>>> myDB = cx_Oracle.Connection(‘scott’,’tiger’,’orcl’)>>> print myDB.version12.1.0.2.0I work with Oracle Endeca Information Discovery a lot and am finding myself doing more with Python to overcome shortcomings of ETL tools, so its nice to get cx_Oracle working on my Mac.From Chicago’s West Loop,William SmithREPLYjvasallosays:February18, 2015 at 9:42 amGreat comment. Thanks for the feedback! I’ll add your fix to the updates for others to try as well!REPLYJohnsays:January20, 2015 at 11:02 pmWorked perfect for my macbook pro. Thanks a ton!!REPLYjvasallosays:January21, 2015 at 7:54 amGlad it helped!REPLYrtimsays:October20, 2014 at 9:52 amHi jvasallo –I followed the instructions and it worked w/o any issues and the sym links was correctly created as well.However when I try to import cx_Oracle I get this:Any ideas .. ?Thanks for sharing this article..{ … snipped … }Traceback (most recent call last):File “”, line 1, inFile “build/bdist.macosx-10.9-x86_64/egg/cx_Oracle.py”, line 7, inFile “build/bdist.macosx-10.9-x86_64/egg/cx_Oracle.py”, line 6, in __bootstrap__ImportError: dlopen(/Users/sinhara8/.python-eggs/cx_Oracle-5.1.2-py2.7-macosx-10.9-x86_64.egg-tmp/cx_Oracle.so, 2): Symbol not found: _OCIAttrGetReferenced from: /Users/sinhara8/.python-eggs/cx_Oracle-5.1.2-py2.7-macosx-10.9-x86_64.egg-tmp/cx_Oracle.soExpected in: flat namespacein /Users/sinhara8/.python-eggs/cx_Oracle-5.1.2-py2.7-macosx-10.9-x86_64.egg-tmp/cx_Oracle.soREPLYjvasallosays:October20, 2014 at 11:00 amHey rtim,What I would do is, uninstall cx_Oracle. Then check the following:Did you create the symbolic links forln -s libclntsh.dylib.11.1 libclntsh.dylibln -s libocci.dylib.11.1 libocci.dylibLook at the note at the end of the article. For some reason, the version went from 12 to 11. Not sure which one you did.Also, make sure in both your ROOT and User .bash_profile you have the oracle settings. Before, you run your install make sure you do echo $ORACLE_HOME to make sure your settings took. There is an issue with root not automatically sourcing the bash_profile onMac. You can do: source .bash_profileREPLYrtimsays:October20, 2014 at 11:15 amHey jvasallo –Thx for posting so quicklyThe sym links and everything is correct ..But I realized after posting the questionthat I made a stupid oversight and installed 32bit oracle clients instead of 64 Bit ..I will revert everything and try again .. will update the post ..REPLYjvasallosays:October20, 2014 at 2:09 pmThat can usually do it. I’ve seen 32/64 bit oracle issues take down a few people. In setup, hope that was just it!REPLYMariosays:October5, 2014 at 11:07 amOS X Version: 10.9.5Python 2.7Hi, Everything went smooth until: sudo python setup.py installAnd I got:Traceback (most recent call last):File “setup.py”, line 135, inraise DistutilsSetupError(“cannot locate an Oracle software ” \distutils.errors.DistutilsSetupError: cannot locate an Oracle software installationFolks on SO are advising to get the client SDK… but that’s already done and installed in my ~/oracle/instantclient_11_2 from steps above! Do you know why it can’t find that?REPLYMariosays:October5, 2014 at 11:13 amImportant note:echo $ORACLE_HOME gives /Users/MYUSER/oracle/instantclient_11_2 as required.REPLYjvasallosays:October5, 2014 at 11:20 amHowdy Mario. I had a similar issue recently. I’ve started in getting the habit of not installing stuff on the root of my system but rather using virtualenvs. Regardless, I had dependency on this module for some legacy stuff :x.1) I found out it is usually due to root not sourcing .bash_profile correctly. Can you try sudo su and then source ~/.bash_profile? Also make sure the library paths for python are set correctly. For me, I have my core OSX Python but a /usr/local/bin/pip. Thismeans my core python would never load the modules installed locallyIadded this and all was good. export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python2.7/site-packages2) Instead of trying to install it by building and such. I had better success, using pip. Can you try sudo pip install cx_Oracle? Also, make sure the paths are set in both the root and user profile.REPLYMariosays:October5, 2014 at 2:51 pmOK so good news and bad news.source’ing roots .bash_profile and then installing worked.pythonimport cx_Oracledid not complain.Then I tried putting import cx_Oracle in IDLE and also in a sript run from IDLE and I got this mess:Traceback (most recent call last):File “”, line 1, inimport cx_OracleFile “build/bdist.macosx-10.6-intel/egg/cx_Oracle.py”, line 7, inFile “build/bdist.macosx-10.6-intel/egg/cx_Oracle.py”, line 6, in __bootstrap__ImportError: dlopen(/Users/MYUSER/.python-eggs/cx_Oracle-5.1.3-py2.7-macosx-10.6-intel.egg-tmp/cx_Oracle.so, 2): Library not loaded: /ade/b/3071542110/oracle/rdbms/lib/libclntsh.dylib.11.1Referenced from: /Users/MYUSER/.python-eggs/cx_Oracle-5.1.3-py2.7-macosx-10.6-intel.egg-tmp/cx_Oracle.soReason: image not foundI actually went looking for a manual method to build because:sudo pip install cx_Oraclegives:Command python setup.py egg_info failed with error code 1 in /private/tmp/pip_build_root/cx-OracleStoring debug log for failure in /Users/MYUSER/Library/Logs/pip.logSo, at least I made it a little further.REPLYjvasallosays:October6, 2014 at 11:19 amHmm…I also ran into this scary issue. Are you running this in a virtualenv?REPLYMariosays:October7, 2014 at 7:10 pmNope. This is OS 10.9REPLYjvasallosays:October7, 2014 at 8:36 pmHmm…ok. I think I know what the problem could be. Is there anyway we can do a Google Hangout or something?REPLYMariosays:October12, 2014 at 12:40 pmHi, I think I may have the solution but need to find time to work on this project again. Thanks for all your help, I will post again!jvasallosays:October12, 2014 at 5:30 pmGlad to help. If you come up with the fix, let me know so I can add it to the article!Bestof luck!REPLYKylesays:April9, 2015 at 12:56 pmOut of curiosity… what was the fix? I’m running into this same issue?NickLinskysays:October22, 2014 at 9:02 amI also had the “cannot locate an Oracle software” problem, although I had it on the “sudo python setup.py build” step. The solution was to use visudo to add ORACLE_HOME to the list of environment variables not blocked by sudo – or something like that – I foundthe details here: http://lorcancoyle.org/wiki/public/cxoracle,and they worked like a charm.REPLYDineversays:June18, 2014 at 4:57 amThis post really helps, thank you!REPLYJatalsays:May2, 2014 at 5:57 pmThis worked perfectly, thanks!REPLYIsmaelsays:March16, 2014 at 1:18 pmMy current OS Version is:OS X Version: 10.9.2Build: 13C64After all the configuration is done, while I try to build the setup.py; I get this error:running buildrunning build_extbuilding ‘cx_Oracle’ extensioncc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -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/opt/oracle/instantclient_10_2/sdk/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c cx_Oracle.c -o build/temp.macosx-10.9-intel-2.7-10g/cx_Oracle.o -DBUILD_VERSION=5.1.2clang: error: unknown argument: ‘-mno-fused-madd’ [-Wunused-command-line-argument-hard-error-in-future]clang: note: this will be a hard error (cannot be downgraded to a warning) in the futureerror: command ‘cc’ failed with exit status 1REPLYjvasallosays:March16, 2014 at 2:23 pmAh looks like you are facing the XCode 5.1 . Can you try and run the command with this before it:CFLAGS=-Wunused-command-line-argument-hard-error-in-futureex:
CFLAGS=-Wunused-command-line-argument-hard-error-in-future sudo python setup.py build
alternatively:
export ARCHFLAGS="-Wno-error=unused-command-line-argument-hard-error-in-future"
sudo python setup.py build
Regardless you are not the only one. 5.1 introduced a lot of headaches with not only Python eggs based but also Ruby gems.If you wish to read more about it: http://stackoverflow.com/a/22355874Let me know if this helps and works! If not, we can try to resolve it further. If it does, I want to add this the tutorial and see if I can work with cx_Oracle to patch this.REPLYDominicGilessays:March29, 2014 at 12:36 pmHi… I’m on Xcode 5.1 as well.I tried both of your approaches and get the same error.running buildrunning build_extbuilding ‘cx_Oracle’ extensioncc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -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/Users/dgiles/instantclient_11_2/sdk/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c cx_Oracle.c -o build/temp.macosx-10.9-intel-2.7-11g/cx_Oracle.o -DBUILD_VERSION=5.1.2clang: error: unknown argument: ‘-mno-fused-madd’ [-Wunused-command-line-argument-hard-error-in-future]clang: note: this will be a hard error (cannot be downgraded to a warning) in the futureerror: command ‘cc’ failed with exit status 1Any other thoughts on how to work round this?REPLYjvasallosays:March29, 2014 at 12:43 pmDom,Looks like I possibly got a bit lazy. Can you try these three:1)
>> CFLAGS=-Wunused-command-line-argument-hard-error-in-future python setup.py build
2)
>> export ARCHFLAGS="-Wno-error=unused-command-line-argument-hard-error-in-future";
>> python setup.py build
3)
>> export CFLAGS="";
>> python setup.py build
REPLYDominicGilessays:March29, 2014 at 4:43 pmHi Joel… I think I’m pretty close… However. It seemed to compile and install.I’m not sure how clear this going to be… but I’ve pasted the results of the install and running a simple cx_oracle import.http://pastebin.com/fg54Y3YBADMIN EDIT: Sorry, normally don’t edit comments but for sake of readability I put the trace in pastebin.REPLYjvasallosays:March29, 2014 at 5:09 pmDom,Which of the options helped you? I am going to take a crack and say it was the last one (which is the worst one sadly…:/).On your terminal can you just:pythonimport cx_OracleREPLYDominicGilessays:March29, 2014 at 5:13 pmHi Joel…Sorry embedded in that mass of text was just that test import cx_oracle.The pertinent error I get at the end of it isImportError: dlopen(/Library/Python/2.7/site-packages/cx_Oracle-5.1.2-py2.7-macosx-10.9-intel.egg/cx_Oracle.so, 2): Symbol not found: _C_SendHTTPRequestReferenced from: /Users/dgiles/instantclient_11_2/libnnz11.dylibI’ve check my paths… I think I’me good i.e.echo $DYLD_LIBRARY_PATH/Users/dgiles/instantclient_11_2Any other thoughts?REPLYjvasallosays:March29, 2014 at 5:20 pmDom,did you see my edit I just added today? I might have told you all to link to the wrong file. Oracle did a switch on me!Canyou:cd /Users/username_here/oracle/instantclient_11_2/unlink libclntsh.dylibunlink libocci.dylibln -s libclntsh.dylib.11.1 libclntsh.dylibln -s libocci.dylib.11.1 libocci.dylibREPLYDominicGilessays:March29, 2014 at 5:21 pmHi JoelJust cracked it… I was using an old instance client. The shame of it. I work for Oracle too…Are you still looking for work?REPLYjvasallosays:March29, 2014 at 5:35 pmDom,PEBKAC, happens all the timeGladto hear you got it up and running! Unfortunately, at this time I am not looking for work, but you know how the world is. Feel free to send me a Linkedin request, or just keep in touch!Also out of curiosity, did any of my three solutions in the previous comment help you get past the build step? I would like to add it to the above for now. Long term, looks like some work needs to be done with cx_Oracle cause its a compiler flag issue. :XREPLYDominicGilessays:March29, 2014 at 5:46 pmHi Joel…It’s not unfortunate that you’re not looking for work.. Thats good newsIfthings change you’ll be able to find me. to be honest I’m not sure which one cleared it… I tried all of them. and they all seemed to give the error. I then played around with some 32.64 bit settings… still got the error. Retried them one after another andhey presto… the first one worked. I really need to clean it all down and restart again. I know my way round Java but have checking out Python and have been pleasantly surprised by how easy things have been… I thought I’d try out the Oracle interfaces… Muchharder than it needs to be. I’ll have to see what I can do to get some support behind the open source efforts… Thanks for your time… I’ll keep an eye on your blog.REPLYjvasallosays:March29, 2014 at 5:54 pmSometimes thats the way it is, and glad this might make an impact with the open source support! Have a good weekend and I’ll be sure to keep in touchREPLYAlexsays:February13, 2014 at 5:47 amTHANKS! The file I downloaded had different .dylib files… for some reason they changed them to 11.1 instead of 11.2REPLYjvasallosays:February13, 2014 at 4:03 pmAwesome! Glad it helped! BTW, the reasoning for the change in version number is to match the version of instant client. I believe 11.1 matches 11.1 instant client and 11.2 is for 11.2 instant client!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: