uswgiインストール時のエラー対応

uswgiインストール時のエラー対応についてご紹介します。

条件

  • Ubuntu 18.04.3 LTS
  • Python 3.6.8

uswgiインストール時のエラー

以下のコマンドでuswgiインストールを行う際、エラーになる場合があります。

$ pip3 install uwsgi

エラー内容の例

  • error: invalid command ‘bdist_wheel’
  • raise Exception(“you need a C compiler to build uWSGI”)
  • plugins/python/uwsgi_python.h:2:20: fatal error: Python.h: No such file or directory

原因

必要なライブラリが不足しているために発生するエラーです。

対応方法

必要なライブラリをインストールします。

pip install wheel
apt-get install build-essential python
sudo apt-get install python3.6-dev

⇒ 今回は”Python 3.6.8″のため、「python3.6-dev」としています。
Pythonバージョンに対応するものをインストールします。

  • Python 3.5の場合:python3.5-dev
  • Python 3.7の場合:python3.7-dev

再実行

uswgiインストール

$ pip3 install uwsgi
Collecting uwsgi
  Using cached https://files.pythonhosted.org/packages/e7/1e/3dcca007f974fe4eb369bf1b8629d5e342bb3055e2001b2e5340aaefae7a/uwsgi-2.0.18.tar.gz
Building wheels for collected packages: uwsgi
  Running setup.py bdist_wheel for uwsgi ... done
  Stored in directory: /home/ubuntu/.cache/pip/wheels/2d/0c/b0/f3ba1bbce35c3766c9dac8c3d15d5431cac57e7a8c4111c268
Successfully built uwsgi
Installing collected packages: uwsgi
Successfully installed uwsgi-2.0.18
$

uswgiバージョン確認

$ uwsgi --version
2.0.18
$

参考

stackoverflow:Error installing uwsgi in virtualenv

https://stackoverflow.com/questions/44037637/error-installing-uwsgi-in-virtualenv

Qiita:uwsgiをEC2インスタンスにインストールしようとして失敗した話

https://qiita.com/hayatetabata/items/111987d1b2b544f6185c

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です