Article reprint Address:
http://blog.csdn.net/intel80586/article/details/8487682 +http://www.myexception.cn/operating-system/1616547.html
MAC OSX uses Python to install module problems
System environment: MAC OSX 10.9.2
Python version: 2.7.5
The new beginning of the RMBP, with the Python environment, but put it into the production environment, there are various problems, first of all, the most deadly, is the installation module problems, resulting in the development has not been normal, the following is my installation of the Python module, the appearance and resolution, summarized as follows, Hope to be helpful to the later (take Mysql-python example, install PIL also encountered the same problem):
(1) Whether using the Easy_install installation module or downloading the installation package, the sudo python setup.py build installation will appear:
******
Error:command ' CC ' failed with exit status 1
Clang:error:unknown argument: '-mno-fused-madd ' [-wunused-command-line-argument-hard-error-in-future]
Clang:note:this'll be a hard error (cannot is downgraded to a warning) in the future
Error:command ' CC ' failed with exit status 1
After a series of searches: Http://www.tuicool.com/articles/zI7Vzu, seemingly mac The OS Xcode from 5.1 to the compiler specifies that for an unknown parameter incoming to be treated as error, we need to downgrade the error to warning using archflags, so the final installation command should look like this:
sudo archflags=-wno-error=unused-command-line-argument-hard-error-in-future easy_install MySQL-python
So, the problem is solved, successfully installed on the Mysql-python
(2) Although the installation of Mysql-python, in the code development process, run the code, the problem arises again:
******
Import MySQLdb
File "build/bdist.macosx-10.9-intel/egg/mysqldb/__init__.py", line A, in <module>
File "build/bdist.macosx-10.9-intel/egg/_mysql.py", line 7, <module>
File "build/bdist.macosx-10.9-intel/egg/_mysql.py", line 6, in __bootstrap__
Importerror:dlopen (/users/kris/.python-eggs/mysql_python-1.2.5-py2.7-macosx-10.9-intel.egg-tmp/_mysql.so, 2): Library not Loaded:libmysqlclient.18.dylib
Referenced from:/users/kris/.python-eggs/mysql_python-1.2.5-py2.7-macosx-10.9-intel.egg-tmp/_mysql.so
Reason:image not found
After looking, I added two symbolic links (soft links):
sudo ln-s/usr/local/mysql/lib/libmysqlclient.18.dylib/usr/lib/libmysqlclient.18.dylib
sudo ln-s/usr/local/mysql/lib/usr/local/mysql/lib/mysql
Run the program again and the problem is resolved.
艹, finally put the python-mysql installed, took me 7 hours of time. It's hard to put on a Mac.
While still remember the middle of the problem is how to solve, quickly write out, one is convenient for everyone to solve the problem, the second is I re-install the system after you leave a procedure.
If someone needs me to provide the software, can leave a message. Although I am not very csdn. Ha ha.
Prerequisite review: My computer is the latest operating system for Mac OS X 10.8.2.
------------------------------------------------------------------------------
Software that needs to be prepared:
1. The python that comes with Mac X looks like a 64-bit. You have to make sure you confirm it yourself.
2, install MySQL, this you can go to put the dog to search, what, not? No? What are you waiting for, M ...
Provide the software name, look for the mother put the dog a search is the ~ ~
Mysql-5.5.29-osx10.6-x86_64.dmg
Mysql-workbench-gpl-5.2.45-osx-i686.dmg
3, Installation Python-mysqldb
========= you can first try the first kind of ==========
This several versions, networking download, open terminal Run as follows, you can not do it yourself try, if successful, then congratulations, if you fail, walk you ~ ~
#sudo easy_install mysql-python
OK, the second kind of ... First statement ~ If you and I like the computer, I reckoned you and I will certainly have the same problem. If there is a similarity which is nanyou.
Well, no nonsense, I use the Mysql-python-1.2.3.tar. You don't know where this is? No problem, M i ~ Although I will not tell you my contact information.
Decompression: what order? Check it yourself, and you'll remember it next time. Old eat ready, never remember, Yuan Fang, how do you think?
---
After decompression, the terminal CD in, with your favorite editor site.cfg (add a bracket, emphasizing the Mysql-python file OH. )
One line #mysql_config = Mysql_config =/usr/local/bin/mysql_config
Remove the previous comment, according to your computer MySQL actual installation directory to fill in, if you go all the way next, it should be the following.
Mysql_config =/usr/local/mysql/bin/mysql_config
You get a terminal yourself CD this directory, can CD in the O.
And then can not be installed, but also to install a pit dad things, gcc this thing good ah, unfortunately 10.8.2 do not bring ah, nothing to install it.
The elder brother also is oneself to put over. I just said my own operation Ha, if you have other ways to install GCC yourself, then skip, I this outfit is very slow. Because it's going to go to the app Store to get Xcode, this thing is really big. Have patience slowly come, ha ~ ~ Wait for you to finish, I also want to tell you, you still did not install the GCC, whether you believe it or not, anyway I believe!! Because you want a JB thing called Command_line_tools, put on this thing you can really have gcc (voiceover "under your sister's GCC ah, the Internet has no Xcode installation, I do not listen to your"--!) Elder brother is the traditional type, only according to the original way to operate, if a friend with the use of the non-Xcode GCC can use, but also please give me a message, but also let me this mountain village to accept a new "posture", I represent my own thank you. "Command_line_tools this thing about 100MB, seemingly need developer account to get it, online have their own, can not find?" I can't find M.
When you're done with GCC, you can see if it's successful in the terminal.
$ which GCC
/usr/bin/gcc
Have output? o The ~
What do you do next? The Mysql-python can be installed.
Or in the directory of which package is installed, run as follows.
#python setup.py Clean
#python setup.py Build
#python setup.py Install
If the hint is not looking for a directory, then add a sodu in front. Not yet, I can only say that the notebook is not yours!!!
The method I'm talking about doesn't work? Then you let the dog continue to look for Niang. I can do it anyway.
Then terminal into Python
#python
>>>import MySQLdb
>>> a mess of things
The above error to edit another JB thing, in/users/xxxx (XXX is the directory you installed) you ls-al find a. Profile hidden JB file, at the end of the last edit append line, as follows.
Export dyld_library_path= "/usr/local/mysql/lib"
Save exit and then re-enter into Python import a bit mysqldb