Getting started with GraphLab and installing Python, iPython Notebooks

I am following the R programming language for some time. But sometimes, I wonder how Python would have worked in those scenarios.  After all, Python has more followers. So, one fine morning I decided to set my hands on Python.

I opted for a Coursera Course on “Machine Learning Foundations: A Case Study Approach” which I liked because it started at the very basic of Python and followed a case study approach.

I downloaded Python 3.7.2  for Mac OS X, which is the latest version.  But, this particular course is using Graphlab Create and I needed a different version of Python.

GraphLab Create:

GraphLab Create is a highly scalable machine learning library for Python, which also includes the SFrame, a highly-scalable library for data manipulation.

So, my this post is more about running iPython notebook and GraphLab Create locally on my own computer.

Below are the steps to install and run the GraphlLab Create:

1. GraphLab Create is not free software. But they provide a 1-year, renewable license for educational purposes.  So first, Register for GraphLab Create at turi and a product key will be emailed to the registered address.

2. Since I have Mac(10.12.6 ), I downloaded “Graphlab Create Launcher” for Mac OS X here.

3. Once downloaded, I added the GraphLab Launcher to the Applications Folder and started the installations.

4. Provided the product key and followed the installation instructions. So, the Launcher will do the following:

5. But sadly for me, the launcher ended in an error.

Error:

The Log says below:

===============================================================
WARNING: could not import _license.show_info
# try:
# $ conda install -n root _license
===================
There was a problem creating the "gl-env" conda environment.  Restart GraphLab Create Launcher.
Process completed with exit code -1

===============================================================

On checking the log more closely, it showed the python version 2.7.13 is installed. Anaconda installation did not clash with the existing Python installation. I have both the versions now.

I navigated to the path where I had installed the “Anaconda” package and there is an “envs” folder which is empty.

Solution:

I launched the navigator and on the “Environments” tab, I saw one “create” option.
Provided the Environment name as “gl-env” and did OK.

“gl-env” is created after some time.

That being done, still, I was not sure if I have everything ready to use GraphLab. So, I decided to start with the course and see how far I can proceed.

Next step is to launch iPython notebook from Home. So, click on Launch at Jupyter notebook.

To create a new iPython Notebook, navigate to New -> Python2

Thus, a new blank iPython Notebook is launched and type

"import graphlab"

Immediately it resulted in an error saying ” No module named graphlab”.

Hmmm, so GraphLab Module is not installed. What next? I followed the steps mentioned here.

What next?

1. Open a Terminal from gl-env environment.

2. Run the below commands as mentioned in the above link:

Since Anaconda is already installed, I skipped the first 2 steps. But while trying to create a new Conda environment, I was getting an error:

bash: conda: command not found

To get rid of that error I used the below command first to set the path:

export PATH=~/anaconda/bin:$PATH

2.  #Create a new Conda environment with Python 2.7.x

# Since I already created the environment manually, this step is also not required and on running the below command it will say that it already exists.

conda create -n gl-env python=2.7 anaconda=4.0.0

3. # Activate the Conda environment

source activate gl-env

4. # install pip

conda install pip

5. # Install your licensed copy of GraphLab Create

pip install --upgrade --no-cache-dir https://get.graphlab.com/GraphLab-Create/2.1/your registered email address here/your product key here/GraphLab-Create-License.tar.gz

Now, GraphLab is installed. Let’s go back to my iPython Notebook and check if I can import graphlab. But first, make sure to terminate all the terminals and close the Navigator and reopen it.

“import graphlab” was still giving me the same error. I checked graphlab is installed. What can be the issue?  Let’s check the paths:

import sys

sys.path

sys.path.append('/Users/oindrilasen/anaconda/envs/gl-env/lib/python2.7/site-packages')

And Voila, it worked! The issue was the path. So I need to append the path where I have installed GraphLab each time I am importing the GraphLab package. Got It!

Thank You!

0

6 comments

  1. Oindrila Sen

    I am really glad that it worked out for you.
    Also, Thank You so much for updating the workaround you followed. It might help others in the similar situation.
    Thanks Pamela !

  2. Pamela

    1. The path was already included in the sys.path. I did not look to see what was in that folder.
    2. I did. My terminal showed that I was in gl-env in my anaconda folder.
    3. I saved the Turi link which included my email address and product ID. I used the pip instructions with that link.

    Right after I posted my comment here, I decided to try again. I'm running the latest version of High Sierra. I thought that maybe what I was installing was too old for my computer setup. I submitted my question in the discussion forum. I got a reply from someone taking the course using a Mac with the latest version of Mojave. They were having similar problems but was able to install graphlab. Here is what worked for them and for me.

    * Installed the latest version of Anaconda using script – bash /PathToScript/Anaconda3-2019.03-MacOSX-x86_64.sh
    * Open the Anaconda Navigaor app and created environment gl-env
    * Click arrow next to that environment name and select “Open Terminal”.
    * python -m pip install pip==9.0.1; downgraded the version of pip
    * python -m pip install tornado==4.5.3; downgraded the version of tornado from 5.1.1
    * pip install –upgrade –no-cache-dir https://get.graphlab.com/GraphLab-Create/2.1/email/productkey/GraphLab-Create-License.tar.gz
    * conda install ipython-notebook
    * pip install matplotlib

    Tornado nor matplotlib were mentioned in the course instructions. I'm not familiar with either of them.

    Put the following at the beginning of each notebook:

    * import sys
    * sys.path
    * sys.path.append('/PathToAnaconda/anaconda3/envs/gl-envs/lib/python2.7/site-packages')
    * import matplotlib
    * import graphlab

    I did not need to append the path. It was already included as before. The import graphlab statement finally worked. I have continued the course.

  3. Oindrila Sen

    Hi Pamela,

    I am not sure what is the exact problem with your graphlab. But checking the below points may help to resolve your issue:
    1. Go to the path where you have installed Anaconda and check if you can see your graphlab package at that path. For me, it is "anaconda/envs/gl-env/lib/python2.7/site-packages". You need to pass the exact path for you in the last append statement.

    2. Did you activate the conda Environment – my step 2?

    3. Did you install your licensed copy, passing your product key?

    Sometimes a small silly mistake like copying the correct path can do the trick. If you are still stuck, you can send me the screenshots that I have added above to me(sen.oindrila@gmail.com) and I will try my best to help.
    Thanks!

  4. Pamela

    I created a new notebook in the folder where Anaconda is located. I executed the first two commands using sys. The output included the path you are appending in the third command. I still get the error. I tried again with a brand new notebook and executed all three commands and still got the same error.

Leave a Reply

Your email address will not be published. Required fields are marked *