14

I am taking ML course in Coursera and I have installed GraphLab Create and ipython notebook.I am new to ML and python.

I get the following error,

import graphlab
sf = graphlab.SFrame('people-example.csv')

AttributeError Traceback (most recent call last) in ()

----> 1 sf = graphlab.SFrame('people-example.csv')

AttributeError: 'module' object has no attribute 'SFrame'

How do I fix this error?I have the people-example.csv in the correct path and no spelling mistake on SFrame Any help is greatly appreciated.Thank you.

Community
  • 1
  • 1
Lotus
  • 225
  • 1
  • 4
  • 13

7 Answers7

24

In your iPython/Jupyter notebook follow these steps in this particular order.

  1. This will download and install dependencies. graphlab.get_dependencies()
  2. Restart Kernel : Kernel > Restart

  3. Now import graphlab: import graphlab

  4. sf = graphlab.SFrame('people-example.csv')

Hope this helps. Cheers!

Maverick
  • 544
  • 3
  • 14
  • I ran this `graphlab.get_dependencies()` in notebook but got an issue. `NameError Traceback (most recent call last) in () 1 #import graphlab ----> 2 graphlab.get_dependencies() NameError: name 'graphlab' is not defined` – Sonal Jan 22 '18 at 10:25
4

Make sure the library graphlab is updated and works with your current python version. Changes on built-in libraries from python 2x to 3x are likely to cause issues like this one.

Saelyth
  • 1,694
  • 2
  • 25
  • 42
  • 1
    Thank you very much.Initially,I got an error when I ran import graphlab stating that I need to give write permission to the folder that had graphlab and to run graphlab.get_dependencies() .By running this function you agree to the following licenses. * libstdc++ : https://gcc.gnu.org/onlinedocs/libstdc++/manual/license.html *xz:http://git.tukani.org/?p=xz.git I just unchecked the readonly option for the graphlab folder.I tried to run import graphlab and there were no errors.But I was getting the attribute error for the next one; sf = graphlab.SFrame.read_csv('people-example.csv') – Lotus Aug 14 '16 at 05:50
  • 1
    The fix was simple.I had to run the graphlab.get_dependencies().I got the following, downloading xz extracting xz and I had to close and restart ipython. Everthing is find now.Appreciate all your replies.Thank you!!! – Lotus Aug 14 '16 at 05:50
  • No worries. I suggest you to answer your own question and then mark it as the valid answer so it doesn't keep appearing on the unanwsered ones. (My english sucks today). – Saelyth Aug 15 '16 at 03:53
4

At first, you should run:

import graphlab
graphlab.product_key.set_product_key('your product key here')

where product_key is a key you received to your email after registering on turi.com with your Coursera credentials.

After this operation everything's going to work fine.

aIKid
  • 26,968
  • 4
  • 39
  • 65
1

You need to restart the ipython kernel on your iPython/Jupyter notebook for graphlab to see the dependencies in the correct locations.

menu options:

Kernel > Restart

and try again. Worked for me.

MJB
  • 101
  • 1
  • 5
0

I faced the same problem. I followed these steps.

1.Restart kernel

2.import graphlab

3.sf = graphlab.SFrame('people-example.csv')

Then it worked for me.

-1

Change it to:

sf = graphlab.SFrame.read_csv('people-example.csv')
Harrison
  • 5,095
  • 7
  • 40
  • 60
  • Thank you.I changed to sf = graphlab.SFrame.read_csv('people-example.csv') and still get the same error. --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) in () ----> 1 sf = graphlab.SFrame.read_csv('people-example.csv') AttributeError: 'module' object has no attribute 'SFrame' – Lotus Aug 14 '16 at 01:10
-2

ok i was having the same problem today and no one can help me ... but i finally found the solution of this problem .... first when you write the code make sure of some important thing 1- s an f in sframe must be capital 2- the most important when you writing people-example.csv write first 4 letters and hit ((tap)) it will continue the word . and here you are every thing is ok :)