Python Adventures – Setup

I’m following the book Learn Python the Hard Way, recommended by @stevemcgrath. I want to tackle some serious data for security analytics using Python and R as well. Ultimately, I wish to create some cool, easy to understand visualizations. The main goal is to complete the book Data-Driven Security and kick some serious security data analytics.

First, I started by installing Canopy 64 bit on Windows 8.1 and Ubuntu 14.04. This sounds easy, it wasn’t. Neither OS version installation worked out of the box. I adjusted the graphics options in the Canopy main area, both OS versions via: Main Screen, Edit, Preferences, Python, Inline (SVG). I will show both operating systems were feasible.

I then ran the following verification check per Data-Driven Security:

 

import pandas as pd

import numpy as np

np.random.seed(1492)

test_df = pd.DataFrame({ “var1”: np.random.randn(5000) })

test_df.hist()


In Windows, I kept getting an openpyxl versioning error. This took a while to solve. After a few uninstall, re-install, “Kernel died, restarting” errors it all worked!

In Linux, I ran into matplotlib, openpyxl and fttype verison errors.

To solve fttype & matplotlib, I found a solution posted by user3888817 on Stack Exchange:

enpkg –no-deps matplotlib 1.2.1

enpkg –no-deps libpng 1.2.40

enpkg –no-deps freetype 2.4.4

 

To solve the openpyxl errors, I can’t remember where I found it:

sudo apt-get install mercurial

 

To install R, I went to R Studio Desktop Download for Windows

 

To install in Ubuntu I went to the Ubuntu Software Center, RStudio

To install ggplot2, at a terminal session:

 

sudo apt-get install r-base-core

R

In R:

install.packages(“ggplot2”)

 

To verify your R installation, run inside R:

 

library(ggplot2)

set.seed(1492)

test.df = data.frame(var1=rnorm(5000))

ggplot(data=test.df) + geom_histogram(aes(x=var1))

 


 

 

Python and R are now both installed!!! J

 

 

 

 

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: