Install python with homebrew and install django with pip. But it fails when the server starts.
$ python manage.py runserver
ImportError: No module named django.core.management
Launch the Terminal app and check the version
$ python --version
Python 2.7.5
I didn't notice this, and I thought it was Python installed with homebrew, but it was different.
$ which python
/usr/bin/python
I didn't notice the latest version of Python in Mavericks ...
It seems that the installation method of Command Line Tools has changed from Xcode 5.0, so install it with the following command
$ xcode-select --install
Homebrew installation
$ ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
Finally, check if it completed normally with the following command
$ brew doctor
Your system is ready to brew.
When it comes out, it is completed
By entering Python with the brew command, pip (Python package management) is also included.
$ brew install python
Keep pip up to date
$ pip install --upgrade setuptools$ pip install --upgrade pip
Set homebrew and python environment path
echo 'export PATH=/usr/local/bin:/usr/local/share/python:$PATH' >> ~/.bash_profile
source ~/.bash_profile
Confirm
$ python --version
Python 2.7.5
$ which python
/usr/local/bin/python
$ pip install django
Create a project
django-admin.py startproject sample_project
This will create a directory called sample_project
in the current directory, so let's move it.
cd sample_project
python manage.py runserver
Access http://127.0.0.1:8000/
, and if the following screen is displayed, the environment construction is complete.
Recommended Posts