LoginSignup
2
0

More than 5 years have passed since last update.

DjangoでrunserverしたらImportError: cannot import name includeが出た。

Last updated at Posted at 2018-03-26

以下のページを参考にやっている途中にimporterrorが出て3時間くらい原因がわからず詰まったので、メモ。
https://docs.djangoproject.com/ja/2.0/intro/tutorial01/ 「はじめてのDjangoアプリ作成」

環境 
OS Linux ubuntu
python2 2.7.6
python3 3.4.3
Django 1.11.11

vagrant Virtualbox
mobaxtermを使用。

URLを書いた後に、以下のコマンドをうって立ち上げたところ
$ python manage.py runserver 0.0.0.0:8000
以下のようなエラーが出ました。
image.png

結論:pythonとDjangoのバージョンが違った(?)みたい。

解決方法
①まず、Djangoのアップデートをします。
$pip3 install Django-U
(ちなみに私はpip3がないよーってエラーが出ました。でなかったらこのまま進んで大丈夫
出た場合は、
$sudo apt-get install python3-pip
の後に
$sudo pip3 install Django-Uを打てば大丈夫です。)

②runserverするときにpythonのバージョンを指定してあげる。
$python3 manage.py runserver 0.0.0.0:8000

動いたー!
Djangoの古いバージョンだとサポートしてない書き方がコード内にあったみたいです。

2
0
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0