I needed to develop Python in the MAMP environment, and when I tried to use SQLAlchemy in the MAMP environment on mac (OS X El Capitan version 10.11.5), I seemed to be lightly addicted to it, so I will summarize the procedure. (As of 2016/06/28)
still, ・ Python 2.7.9 ・ Mysql not installed ・ The following can be used ・ Homebrew ・ Pip ・ Pyenv-virtualenv
Is the premise.
First, build the MAMP environment.
Download from https://www.mamp.info/en/downloads/
Execute the downloaded pkg to install. In addition, MAMP PRO will be installed at the same time, but I didn't need it personally, so I ran uninstaller.app in / Application / MAMP PRO to uninstall it.
If you uninstall after using MAMP PRO, the data inside will be deleted without any questions, and it seems that it may not be uninstalled, so it is recommended that you delete it immediately if you do not need it.
There is no particular effect on this case, so please set up each one.
This is not essential, but for the time being.
$ pyenv virtualenv 2.7.9 hogehoge
$ cd <Application root>
$ pyenv local hogehoge
Install the MySQL driver used by SQLAlchemy.
If you try to install Mysql-Python without doing anything (the following is a partial excerpt)
building '_mysql' extension
creating build/temp.macosx-10.11-x86_64-2.7
clang -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 -I/Applications/MAMP/Library/include -I/Users/fujito/.pyenv/versions/2.7.9/include/python2.7 -c _mysql.c -o build/temp.macosx-10.11-x86_64-2.7/_mysql.o -fno-omit-frame-pointer -g -DNDEBUG
_mysql.c:44:10: fatal error: 'my_config.h' file not found
#include "my_config.h"
^
1 error generated.
error: command 'clang' failed with exit status 1
I can't install it like this.
Mysql to be used is installed by installing MAMP, but it seems to occur because my_config.h is not included here. Therefore, install the required difference file.
$ brew install mysql-connector-c
Completely install Mysql-Python
$ pip install Mysql-Python
Finally (but not the last) install SQLAlchemy
$ pip install SQLAlchemy
Recommended Posts