Minimum notes when using Python on Mac (Homebrew edition)

First, Python is already installed on your Mac. You can use this, but I would like to use the homebrew version.

You can also use pyenv to manage installations and versions used. Here.

environment

Standard state

which python
/usr/bin/python

Installation of brew version

In the brew version, Python 2.x series and Python 3.x series can be installed, and Python 3.x series is installed as Python 3, so you can coexist without thinking. Here, I will use Python 2.x series for the time being.

brew info As you can see by python, it seems that pip is also installed.

brew install python

After installing, try which python again,

/usr/local/bin/python

The brew version (under / usr / local / bin /) is used. This is because / usr / local / bin has priority over / usr / bin by default, so if for some reason the PATH setting is not like that, .bash_profile etc. will take precedence. Define the ranking properly.

Update of modules etc.

It seems that pip wraps setuptools, so update each tool.

pip install --upgrade setuptools
pip install --upgrade pip

It seems that python in the standard state does not include pip. In that case, you can install it with easy_install pip.

Check installed modules

The list is

pip freeze

In can be confirmed. For details on each module, see

pip show <package_name>

You can see it at. The package is

/usr/local/lib/python2.7/site-packages

It seems to be installed in, but this seems to see the same location for both the original python and the brew version of python.

Module installation

Install the required modules. For the time being, the following is sufficient.

pip install numpy
pip install matplotlib
pip install pillow

It seems that numpy is also installed when matplotlib is installed.

Django

For the time being, I'll also write the Django setup. Until It worked!

Installation

pip install django

You can also version it as> pip install django == 1.9.

Project creation

django-admin.py startproject django_test

Start and check the test server

cd django_test
python manage.py runserver

Try accessing http://127.0.0.1:8000/ with your browser. It worked! Is OK.

There is a bug in 2.7.11 installed by brew and it doesn't start properly. It seems to be okay if 2.7.10 is already included. It doesn't seem to work for a clean install. I wrote about the countermeasures in here.

Recommended Posts

Minimum notes when using Python on Mac (Homebrew edition)
Minimum memo when using Python on Mac (pyenv edition)
Notes on installing Python on Mac
Notes on setting pyenv and python environment using Homebrew on Mac OS Marvericks
Notes on using MeCab from Python
Notes on installing Python using PyEnv
Notes on using rstrip with python.
(Beginner) Notes on using pyenv on Mac
Notes for using OpenCV on Windows10 Python 3.8.3.
Error and solution when installing python3 with homebrew on mac (catalina 10.15)
Notes on building Python and pyenv on Mac
python on mac
Error, warning when using TensorFlow on Mac
Video processing using Python + OpenCV on Mac
Notes on using code formatter in Python
[Definitive Edition] Building an environment for learning "machine learning" using Python on Mac
Notes on installing Python3 and using pip on Windows7
Notes on using dict in python [Competition Pro]
[Python] Notes on accelerating genetic algorithms using multiprocessing
Install Python on Mac
Install Python 3 on Mac
Install Python 3.4 on Mac
Notes using Python subprocesses
Notes on using Alembic
Install Python3 on Mac and build environment [Definitive Edition]
Check types_map when using mimetypes on AWS Lambda (Python)
Installation method when using RealSense from Python (pyenv edition)
Build a Python environment on your Mac using pyenv
Troublesome story when using Python3 with VScode on ubuntu
How to exit when using Python in Terminal (Mac)
Python notes using perl-ternary operator
Install pygame on python3.4 on mac
Python notes using perl-special variables
[Django] Notes on using django-debug-toolbar
Python installation (Mac edition) (old)
Handling of python on mac
Update python on Mac to 3.7-> 3.8
Install pandas 0.14 on python3.4 [on Mac]
Notes on optimization using Pytorch
Notes on installing pipenv on Mac
Notes on installing Python on CentOS
Using OpenCV with Python @Mac
Using multiple versions of Python on Mac OS X (2) Usage
Create a Python (pyenv / virtualenv) development environment on Mac (Homebrew)
Using NAOqi 2.4.2 Python SDK on Mac OS X El Capitan
Building a Python environment on a Mac and using Jupyter lab
Easy on Mac! Plot of unit step response using Python
Building a Python environment on Mac
Notes on Python and dictionary types
Precautions when using pit in Python
Error when building mac python environment
Minimum grammar notes for writing Python
Using multiple versions of Python on Mac OS X (1) Multiple Ver installation
Implement TensorFlow Lite on Mac [2019 Edition]
Introducing Python using pyenv on Ubuntu 20.04
Stream speech recognition using Google Cloud Speech gRPC API on python3 on Mac!
Preparing python using vscode on ubuntu
Ansible playbook for setting up Python preferences using pyenv on Mac
Create a Python environment on Mac (2017/4)
Introducing OpenCV on Mac with homebrew
Notes on using post-receive and post-merge