AdSense

Wednesday, February 21, 2018

Python Machine Learning (Deep Learning) Runtime Environment Set-up on macOS

[1] Intended Readers

This article is for:
  • Python beginners
  • Python single user (for yourself, but not for a team/project with virtual environments)

[2] System Environment

macOS High Sierra
Version 10.13.3

[3] Installing Package Manager: Homebrew

  • A package manager enable you to install a package software automatically via the internet.
  • You don't need to search the web, download files, and then install them on your computer.

Access the website:
https://brew.sh

Copy a script:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Start Terminal on your macOS.
Paste the script above and press return.
Enter password of your macOS and press return.

After a few minutes, check whether Homebrew is correctly installed. On Terminal, type and enter:
which brew
It returns:
/usr/local/bin/brew


[4] Installing Python

which python3
If it returns like the following, then you don't need to re-install Python:
/Library/Frameworks/Python.framework/Versions/3.6/bin/python3

If it does not return anything, then type the following Homebrew command on Terminal to (re-)install Python.
brew install python3

Type on Terminal:
which python3

It reruns:
/Library/Frameworks/Python.framework/Versions/3.6/bin/python3

When you install Python via Homebrew, then you also install pip3,
which pip3

It returns:
/Library/Frameworks/Python.framework/Versions/3.6/bin/pip3

pip3 is a tool to manage libraries for Python.


Homebrew manages software such as python3, pip3, on macOS. pip3 manages libraries for python3.

On Terminal, type and return:
python3 --version
Python 3.6.4

On Terminal, install useful libraries for Python:
pip3 install numpy  # linear algebra
pip3 install scipy  # mathematical formula manipulation
pip3 install matplotlib   # drawing, plotting
pip3 install pandas  # data(base) manipulation

pip3 install scikit-learn # machine learning package

pip3 install tensorflow # Google Tensorflow (deep learning libraries )

python
>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
>>> print(sess.run(hello))
b'Hello, TensorFlow!'
# TensorFlow successfully installed.
>>> exit()

pip3 install chainer # Chainer (deep learning libraries made in Japan)

pip3 install jupyter # Easy Python running environment

[5] Installing A Text Editor w/ Runtime Environment: Atom

Access:
https://atom.io

Download an installation file.
Copy the file and paste it to the Applications folder on your macOS.

Open Atom.

Install a Package. Or
Menu > Atom > Preferences > Install


Enter terminal on the "Search packages" textbook and press Packages.
Find "platformio-ide-terminal" and press Install. (Note: You need to install Xcode before this.)

Now you can start Terminal within the Atom text editor; you are able to write codes and run them within Atom. It boosts your productivity.
Press + sign in the bottom left corner of the screen.


Similarly, enter script on the "Search packages" textbook and press Packages.
Find "script" and press Install.

Now you can run your code within the Atom text editor; you are able to write codes and run them within Atom. It boosts your productivity.
Press + sign in the bottom left corner of the screen.


To create a Python executable project folder,
File > Add Project Folder...
Select your folder that contains py script files.


To create a new Python (py) file,
File > New File
File > Save As...
test.py

Write a very simple code:
print('Hello, Python!')

To run the script above,
Packages > Script > Run Script

You can see the result:
Hello, Python!
[Finished in 0.084s]


1 comment:

  1. This post is much helpful for us. this is really very massive value to all the readers and it will be the only reason for the post to get popular with great authority.
    Machine Learning with Python

    ReplyDelete

Deep Learning (Regression, Multiple Features/Explanatory Variables, Supervised Learning): Impelementation and Showing Biases and Weights

Deep Learning (Regression, Multiple Features/Explanatory Variables, Supervised Learning): Impelementation and Showing Biases and Weights ...