Python Environment Setup - nature-of-code/NOC-S17-2-Intelligence-Learning GitHub Wiki
This page is based on Abhiskek's excellent Machine Learning Demystified.
Setup Environment
1) Install miniconda
- Go to https://conda.io/miniconda.html
- Choose Python 3.6 Mac OSX 64-bit (bash installer) and download
- Open terminal and type:
bash /path/to/the/file/you/just/downloaded
(For the path you can drag the bash file you download into your terminal window from where you installed it.)
- Review the license and approve the license terms - type in
yes
and press enter - Press
Enter
again to confirm the location of install - Type
yes
when it asks you if the install location should be prepended to PATH - Restart Terminal for changes to take effect
- Type:
conda info
- If it prints out some stuff then it has installed correctly
2) Create an environment
conda create -n tensor python=3.5.2
You can name it something other than 'tensor' if you prefer. Type: y
(and press Enter). This will create a conda environment with the name 'tensor' and python version 3.5.2
3) Turn off conda by default
These instructions will set conda to be your "default" python on your machine (rather than the usual python 2 that comes pre-installed on a mac.) If you would prefer to turn this off, you have to edit your bash_profile
(a configuration file for terminal.) Use these steps.
Edit bash profile with
$ nano ~/.bash_profile
You should see:
# added by Miniconda3 4.3.11 installer
export PATH="/Users/yourname/miniconda3/bin:$PATH"
Change this to:
alias start_conda='PATH="/Users/yourname/miniconda3/bin:$PATH"'
Restart terminal. Now terminal will not use your conda python installation unless you enter start_conda
. You could also consider using something like VirtualEnv instead.
4) Activate environment
$ source activate tensor
You should see (tensor) prepended before your terminal prompt
5) Install Jupyter
Make sure you can see (tensor) prepended before the terminal prompt before proceeding
conda install jupyter
Type y
and press enter.
6) Install python packages
Create a file called requirements.txt
and paste the following into it. You can also grab this requirements.txt
Flask==0.12.1
matplotlib==2.0.0
numpy==1.10.4
scipy==0.17.0
Pillow==4.1.0
keras==2.0.3
image==1.5.5
tensorflow==1.0.0
h5py==2.7.0
Make sure you tensor
environment is activated (you should see (tensor) prepended before your terminal prompt).
pip install -r requirements.txt
To open the Jupyter notebook files:
jupyter notebook
To run one of the flask server examples:
python server.py
Then navigate to localhost:8080
in the browser.