54882
Ubuntu 18.10  
pip 19.1.1  
django 2.2.1

Ubuntuでpythonからmysqlを利用するためにmysqlclientをインストールすると、  
以下のメッセージで失敗します。

```

    Collecting mysqlclient
      Using cached https://files.pythonhosted.org/packages/f4/f1/3bb6f64ca7a429729413e6556b7ba5976df06019a5245a43d36032f1061e/mysqlclient-1.4.2.post1.tar.gz
    Installing collected packages: mysqlclient
      Running setup.py install for mysqlclient ... error
        ERROR: Complete output from command /home/user/PycharmProjects/ygo/venv/bin/python -u -c 'import setuptools, tokenize;__file__='"'"'/tmp/pip-install-1zkhhcyj/mysqlclient/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-hvyu7bch/install-record.txt --single-version-externally-managed --compile --install-headers /home/user/PycharmProjects/ygo/venv/include/site/python3.6/mysqlclient:
        ERROR: running install
        running build
        running build_py
        creating build
        creating build/lib.linux-x86_64-3.6
        creating build/lib.linux-x86_64-3.6/MySQLdb
        copying MySQLdb/__init__.py -> build/lib.linux-x86_64-3.6/MySQLdb
        copying MySQLdb/_exceptions.py -> build/lib.linux-x86_64-3.6/MySQLdb
        copying MySQLdb/compat.py -> build/lib.linux-x86_64-3.6/MySQLdb
        copying MySQLdb/connections.py -> build/lib.linux-x86_64-3.6/MySQLdb
        copying MySQLdb/converters.py -> build/lib.linux-x86_64-3.6/MySQLdb
        copying MySQLdb/cursors.py -> build/lib.linux-x86_64-3.6/MySQLdb
        copying MySQLdb/release.py -> build/lib.linux-x86_64-3.6/MySQLdb
        copying MySQLdb/times.py -> build/lib.linux-x86_64-3.6/MySQLdb
        creating build/lib.linux-x86_64-3.6/MySQLdb/constants
        copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
        copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
        copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
        copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
        copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
        copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
        running build_ext
        building 'MySQLdb._mysql' extension
        creating build/temp.linux-x86_64-3.6
        creating build/temp.linux-x86_64-3.6/MySQLdb
        x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Dversion_info=(1,4,2,'post',1) -D__version__=1.4.2.post1 -I/usr/include/mysql -I/home/user/PycharmProjects/ygo/venv/include -I/usr/include/python3.6m -c MySQLdb/_mysql.c -o build/temp.linux-x86_64-3.6/MySQLdb/_mysql.o
        unable to execute 'x86_64-linux-gnu-gcc': No such file or directory
        error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
        ----------------------------------------
    ERROR: Command "/home/user/PycharmProjects/ygo/venv/bin/python -u -c 'import setuptools, tokenize;__file__='"'"'/tmp/pip-install-1zkhhcyj/mysqlclient/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-hvyu7bch/install-record.txt --single-version-externally-managed --compile --install-headers /home/user/PycharmProjects/ygo/venv/include/site/python3.6/mysqlclient" failed with error code 1 in /tmp/pip-install-1zkhhcyj/mysqlclient/
    
```
CC BY-SA 4.0
2019-05-11T03:30:24.640
54881
2019-05-11T05:28:26.047
34261
question
python mysql ubuntu django
Ubuntuでmysqlclientのインストールに失敗する。
下記のエラーメッセージに注目すると、`gcc`がインストールされていないのが原因だと思われます。

```

    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Dversion_info=(1,4,2,'post',1) -D__version__=1.4.2.post1 -I/usr/include/mysql -I/home/user/PycharmProjects/ygo/venv/include -I/usr/include/python3.6m -c MySQLdb/_mysql.c -o build/temp.linux-x86_64-3.6/MySQLdb/_mysql.o
    unable to execute 'x86_64-linux-gnu-gcc': No such file or directory
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
    
```

Ubuntuなら`apt`コマンドでgccをインストールしてみてください。

```

    $ sudo apt install gcc
    
```
CC BY-SA 4.0
2019-05-11T05:28:26.047
54882
2019-05-11T05:28:26.047
3060
54881
answer