Introducing MAMP + Python + SQLAlchemy (Mysql-Python) on Mac

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.

MAMP setup

First, build the MAMP environment.

download

Download from https://www.mamp.info/en/downloads/ スクリーンショット 2016-06-28 15.42.51.png

Installation

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.

setup

There is no particular effect on this case, so please set up each one.

python work environment preparation

This is not essential, but for the time being.

$ pyenv virtualenv 2.7.9 hogehoge
$ cd <Application root>
$ pyenv local hogehoge

Mysql-Install Python

Install the MySQL driver used by SQLAlchemy.

Install mysql-connector-c

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

Mysql-Python installation

Completely install Mysql-Python

$ pip install Mysql-Python

SQLAlchemy installation

Finally (but not the last) install SQLAlchemy

$ pip install SQLAlchemy

Recommended Posts

Introducing MAMP + Python + SQLAlchemy (Mysql-Python) on Mac
python on mac
Install Python on Mac
Install Python 3 on Mac
Install Python 3.4 on Mac
Install pygame on python3.4 on mac
Handling of python on mac
Update python on Mac to 3.7-> 3.8
Install pandas 0.14 on python3.4 [on Mac]
Notes on installing Python on Mac
Introducing TensorFlow on Ubuntu + Python 2.7
Building a Python environment on Mac
Introducing Python using pyenv on Ubuntu 20.04
Create a Python environment on Mac (2017/4)
Introducing OpenCV on Mac with homebrew
Python environment construction memo on Mac
Install Python 3.7 Anaconda on MAC, but Python 2
Install python3 on Mac (El Capitan)
Environment construction of python3.8 on mac
If Python 3.5.0 installation fails on Mac
Steps to install python3 on mac
Call C / C ++ from Python on Mac
Update Python on Mac from 2 to 3
Create a python environment on your Mac
Follow active applications on Mac with Python
How to erase Python 2.x on Mac.
Notes on building Python and pyenv on Mac
Build Python environment with Anaconda on Mac
Video processing using Python + OpenCV on Mac
Python on Windows
twitter on python3
Build a Python environment on Mac (Mountain Lion)
Run Zookeeper x python (kazoo) on Mac OS X
Build a Python development environment on your Mac
Try working with Mongo in Python on Mac
Put Python 2.7.x on Mac OSX 10.15.5 with pyenv
Python on Windbg
Shpinx (Python documentation builder) on Mac OS X
Try importing MLB data on Mac and Python
Install Python3 on Mac and build environment [Definitive Edition]
I tried Python on Mac for the first time.
Install Python venv --VSCode --GitHub integration environment on Mac
Install selenium on Mac and try it with python
Steps to install the latest Python on your Mac
Build a machine learning Python environment on Mac OS
Preferences to generate animated GIFs from Python on Mac
Build a Python development environment on Mac OS X
Build a Python environment on your Mac using pyenv
Installing Python 3 on Mac and checking basic operation Part 1
I want to AWS Lambda with Python on Mac!
Compile and install MySQL-python for python2.7 on amazon linux
problem that certificate verify failed on mac python pip
Install Python environment on local PC (pyenv, venv on Mac)
Minimum memo when using Python on Mac (pyenv edition)
Minimum notes when using Python on Mac (Homebrew edition)
Python conda on cygwin
Install python on WSL
Install pyenv on mac
PyOpenGL setup on Python 3
Install Scrapy on python3
Pyenv + virtualenv on Mac