web-dev-qa-db-ja.com

パッケージフラスコ-mysqldbをインストールできません

これは私が得るエラーです

Collecting flask-mysqldb
  Using cached https://files.pythonhosted.org/packages/62/e3/955c845efe1aacf30c8e2607470544ede36aa1044f6382c809f13e014104/Flask-MySQLdb-0.2.0.tar.gz
Requirement already satisfied: Flask>=0.10 in ./venv/lib/python3.6/site-packages (from flask-mysqldb)
Collecting mysqlclient (from flask-mysqldb)
  Using cached https://files.pythonhosted.org/packages/f4/f1/3bb6f64ca7a429729413e6556b7ba5976df06019a5245a43d36032f1061e/mysqlclient-1.4.2.post1.tar.gz
Requirement already satisfied: Jinja2>=2.10.1 in ./venv/lib/python3.6/site-packages (from Flask>=0.10->flask-mysqldb)
Requirement already satisfied: Werkzeug>=0.15 in ./venv/lib/python3.6/site-packages (from Flask>=0.10->flask-mysqldb)
Requirement already satisfied: itsdangerous>=0.24 in ./venv/lib/python3.6/site-packages (from Flask>=0.10->flask-mysqldb)
Requirement already satisfied: click>=5.1 in ./venv/lib/python3.6/site-packages (from Flask>=0.10->flask-mysqldb)
Requirement already satisfied: MarkupSafe>=0.23 in ./venv/lib/python3.6/site-packages (from Jinja2>=2.10.1->Flask>=0.10->flask-mysqldb)
Building wheels for collected packages: flask-mysqldb, mysqlclient
  Running setup.py bdist_wheel for flask-mysqldb ... done
  Stored in directory: /home/shubham/.cache/pip/wheels/fd/c9/ef/e0e99dfcf898bc040267e36c4a414ff0b22239968a25161012
  Running setup.py bdist_wheel for mysqlclient ... error
  Complete output from command /home/shubham/venv/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-hhwnbj2k/mysqlclient/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/tmpprwo5hxppip-wheel- --python-tag cp36:
  /usr/lib/python3.6/distutils/dist.py:261: UserWarning: Unknown distribution option: 'long_description_content_type'
    warnings.warn(msg)
  running bdist_wheel
  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/shubham/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

  ----------------------------------------
  Failed building wheel for mysqlclient
  Running setup.py clean for mysqlclient
Successfully built flask-mysqldb
Failed to build mysqlclient
Installing collected packages: mysqlclient, flask-mysqldb
  Running setup.py install for mysqlclient ... error
    Complete output from command /home/shubham/venv/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-hhwnbj2k/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-o0sk9t2l-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/shubham/venv/include/site/python3.6/mysqlclient:
    /usr/lib/python3.6/distutils/dist.py:261: UserWarning: Unknown distribution option: 'long_description_content_type'
      warnings.warn(msg)
    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/shubham/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

    ----------------------------------------
Command "/home/shubham/venv/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-hhwnbj2k/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-o0sk9t2l-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/shubham/venv/include/site/python3.6/mysqlclient" failed with error code 1 in /tmp/pip-build-hhwnbj2k/mysqlclient/

私も同じモジュールをWindowsにインストールしようとしましたが、同様のエラーが発生しました...問題が何であるかわからない...

私の問題はflask-mysqldbをインストールすることさえできないので、質問のタイトルと詳細を更新しました。以前は、このパッケージのインポートエラーのみが表示されていました。

任意の解決策を提案してください...それは今3日です... ubuntuを再インストールしても、まだ解決策がありませんでした。

1
Shubham Pandey

@rtaftによる提案

最初に

pip3 install wheel

続いて行う

Sudo apt-get install build-essential libssl-dev libffi-dev python3-dev

問題を解決します。答えを提案してくれてありがとう@rtaft。

2
Shubham Pandey