Ubuntu first configuration - Price Network example

Hello,
I'm really really new to Ubuntu and Python, so be gentle with me, and
moreover don't give anything for granted with me, thank you!
I installed graph tool via 'sudo apt-get install graph-tool', and everything
seemed to go fine.
I'm now trying to run the example code from the documentation (Price Network
example), but I cannot make it work :frowning:
These are the steps I followed:
1 - sudo gedit first.py
2 - copy and paste of example code
3 - save (so it gets in my home)
4 - python first.py
Here I get the following error:
/Traceback (most recent call last):
File "first.py", line 10, in <module>
from graph_tool.all import *
ImportError: No module named graph_tool.all/

I tried the following:
1: reissue the installing command, but it says that graph-tool is already
installed with last version
2: if I write 'graph-tool --help' it says command not found
3: gcc -v says

/Target: i686-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro
4.6.1-9ubuntu3' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs
--enable-languages=c,c++,fortran,objc,obj-c++,go --prefix=/usr
--program-suffix=-4.6 --enable-shared --enable-linker-build-id
--with-system-zlib --libexecdir=/usr/lib --without-included-gettext
--enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-plugin
--enable-objc-gc --enable-targets=all --disable-werror --with-arch-32=i686
--with-tune=generic --enable-checking=release --build=i686-linux-gnu
--host=i686-linux-gnu --target=i686-linux-gnu
Thread model: posix
gcc version 4.6.1 (Ubuntu/Linaro 4.6.1-9ubuntu3)
/
4: python -v says

/# installing zipimport hook
import zipimport # builtin
# installed zipimport hook
# /usr/lib/python2.7/site.pyc matches /usr/lib/python2.7/site.py
import site # precompiled from /usr/lib/python2.7/site.pyc
# /usr/lib/python2.7/os.pyc matches /usr/lib/python2.7/os.py
import os # precompiled from /usr/lib/python2.7/os.pyc
import errno # builtin
import posix # builtin
# /usr/lib/python2.7/posixpath.pyc matches /usr/lib/python2.7/posixpath.py
import posixpath # precompiled from /usr/lib/python2.7/posixpath.pyc
# /usr/lib/python2.7/stat.pyc matches /usr/lib/python2.7/stat.py
import stat # precompiled from /usr/lib/python2.7/stat.pyc
# /usr/lib/python2.7/genericpath.pyc matches
/usr/lib/python2.7/genericpath.py
import genericpath # precompiled from /usr/lib/python2.7/genericpath.pyc
# /usr/lib/python2.7/warnings.pyc matches /usr/lib/python2.7/warnings.py
import warnings # precompiled from /usr/lib/python2.7/warnings.pyc
# /usr/lib/python2.7/linecache.pyc matches /usr/lib/python2.7/linecache.py
import linecache # precompiled from /usr/lib/python2.7/linecache.pyc
# /usr/lib/python2.7/types.pyc matches /usr/lib/python2.7/types.py
import types # precompiled from /usr/lib/python2.7/types.pyc
# /usr/lib/python2.7/UserDict.pyc matches /usr/lib/python2.7/UserDict.py
import UserDict # precompiled from /usr/lib/python2.7/UserDict.pyc
# /usr/lib/python2.7/_abcoll.pyc matches /usr/lib/python2.7/_abcoll.py
import _abcoll # precompiled from /usr/lib/python2.7/_abcoll.pyc
# /usr/lib/python2.7/abc.pyc matches /usr/lib/python2.7/abc.py
import abc # precompiled from /usr/lib/python2.7/abc.pyc
# /usr/lib/python2.7/_weakrefset.pyc matches
/usr/lib/python2.7/_weakrefset.py
import _weakrefset # precompiled from /usr/lib/python2.7/_weakrefset.pyc
import _weakref # builtin
# /usr/lib/python2.7/copy_reg.pyc matches /usr/lib/python2.7/copy_reg.py
import copy_reg # precompiled from /usr/lib/python2.7/copy_reg.pyc
# /usr/lib/python2.7/traceback.pyc matches /usr/lib/python2.7/traceback.py
import traceback # precompiled from /usr/lib/python2.7/traceback.pyc
# /usr/lib/python2.7/sysconfig.pyc matches /usr/lib/python2.7/sysconfig.py
import sysconfig # precompiled from /usr/lib/python2.7/sysconfig.pyc
# /usr/lib/python2.7/re.pyc matches /usr/lib/python2.7/re.py
import re # precompiled from /usr/lib/python2.7/re.pyc
# /usr/lib/python2.7/sre_compile.pyc matches
/usr/lib/python2.7/sre_compile.py
import sre_compile # precompiled from /usr/lib/python2.7/sre_compile.pyc
import _sre # builtin
# /usr/lib/python2.7/sre_parse.pyc matches /usr/lib/python2.7/sre_parse.py
import sre_parse # precompiled from /usr/lib/python2.7/sre_parse.pyc
# /usr/lib/python2.7/sre_constants.pyc matches
/usr/lib/python2.7/sre_constants.py
import sre_constants # precompiled from /usr/lib/python2.7/sre_constants.pyc
# /usr/lib/python2.7/sitecustomize.pyc matches
/usr/lib/python2.7/sitecustomize.py
import sitecustomize # precompiled from /usr/lib/python2.7/sitecustomize.pyc
# /usr/lib/python2.7/dist-packages/apport_python_hook.pyc matches
/usr/lib/python2.7/dist-packages/apport_python_hook.py
import apport_python_hook # precompiled from
/usr/lib/python2.7/dist-packages/apport_python_hook.pyc
import encodings # directory /usr/lib/python2.7/encodings
# /usr/lib/python2.7/encodings/__init__.pyc matches
/usr/lib/python2.7/encodings/__init__.py
import encodings # precompiled from
/usr/lib/python2.7/encodings/__init__.pyc
# /usr/lib/python2.7/codecs.pyc matches /usr/lib/python2.7/codecs.py
import codecs # precompiled from /usr/lib/python2.7/codecs.pyc
import _codecs # builtin
# /usr/lib/python2.7/encodings/aliases.pyc matches
/usr/lib/python2.7/encodings/aliases.py
import encodings.aliases # precompiled from
/usr/lib/python2.7/encodings/aliases.pyc
# /usr/lib/python2.7/encodings/utf_8.pyc matches
/usr/lib/python2.7/encodings/utf_8.py
import encodings.utf_8 # precompiled from
/usr/lib/python2.7/encodings/utf_8.pyc
Python 2.7.2+ (default, Oct 4 2011, 20:03:08)
[GCC 4.6.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
dlopen("/usr/lib/python2.7/lib-dynload/readline.so", 2);
import readline # dynamically loaded from
/usr/lib/python2.7/lib-dynload/readline.so/

5: if I look for graph-tool on the computer, there are two folders in
usr/share/doc and usr/doc
6: If I look for python on the computer, I see there is both python2.6 and
python2.7 and python3 under usr/lib

7: May it depend on the first row of the code? (#! /usr/bin/env python)
Should it refer to some place in particular?

Feel free to ask for any extra configuration, but if I need to write some
commands, please state them clearly, since I'm a newbie!
Thank you very much!
Fabio

Hi Fabio,

These are the steps I followed:
1 - sudo gedit first.py

You do not need to run "sudo", since there is no need to edit the
program as the superuser.

2 - copy and paste of example code
3 - save (so it gets in my home)
4 - python first.py
Here I get the following error:
/Traceback (most recent call last):
File "first.py", line 10, in <module>
from graph_tool.all import *
ImportError: No module named graph_tool.all/

Is the trailing slash "/" really in the error message?

Try the following to see if graph-tool was properly installed: 1. Type
"python"; 2. inside the python prompt, type "import graph_tool". If not
error is given, then graph-tool was properly installed.

6: If I look for python on the computer, I see there is both python2.6
and python2.7 and python3 under usr/lib

Try the same command as before, but with "python2.6" instead of "python".

Cheers,
Tiago

Hi Tiago,
thank you very much for the very quick reply!

Tiago Peixoto wrote

4 - python first.py
Here I get the following error:
/Traceback (most recent call last):
File "first.py", line 10, in <module>
from graph_tool.all import *
ImportError: No module named graph_tool.all/

Is the trailing slash "/" really in the error message?

No, I'm sorry, it's just a typo... no slash :smiley:

Tiago Peixoto wrote

Try the following to see if graph-tool was properly installed: 1. Type
"python"; 2. inside the python prompt, type "import graph_tool". If not
error is given, then graph-tool was properly installed.

It says:
/Python 2.7.2+ (default, Oct 4 2011, 20:03:08)
[GCC 4.6.1] on linux2/
etc etc... and at import graph_tool it says
/Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named graph_tool/

Tiago Peixoto wrote

6: If I look for python on the computer, I see there is both python2.6
and python2.7 and python3 under usr/lib

Try the same command as before, but with "python2.6" instead of "python".

It says:
/Python 2.6.7 (r267:88850, Aug 11 2011, 12:16:10)
[GCC 4.6.1] on linux2/
etc etc... and at import graph_tool it seems to work, meaning that no error
appears, and the prompt is ready for another command!

So I tried the following command:
python2.6 first.py
and it worked! It created the PDF graph, as expected!

So, the error is that graph_tool is installed in a python version that is
not the default one, is that right?
Which version should graph_tool be installed on? 2.6 or 2.7?
Thank you very much!

Fabio

It seems graph-tool is installed against python 2.6 on ubuntu, so you
have to use that version. In the next version I will make sure it is
installed against the latest version.

Cheers,
Tiago