modulepy2exeigraphcx-freezegui2exe

ImportError: No module named texttable (igraph, py2exe,cx freeze/gui2exe)


I've spent 2 days trying to solve this problem and I'm getting nowhere.

I try to get an executable from my python script.

Script is running with no issues. I build graphs in it by using igraph which is my favorite choice for this task.

After compiling my script I get the results as expected (Dist folder with my exe and its stuff in it)

When I try to run the exe I get this annoying error message:

 File "igraph\__init__.pyc", line 36, in <module>
 File "igraph\clustering.pyc", line 38, in <module>
 File "igraph\summary.pyc", line 36, in <module>
 File "igraph\vendor\__init__.pyc", line 33, in vendor_import
ImportError: No module named texttable

I checked many threads related to ImportError. I went in the folder containing texttable and IT'S THERE! It's not missing! I've tryed something with changing the path but still no succes.

at the beginning of my script I have:

import re
import os
import csv
import math
from igraph import *
import thread
import unicodedata
from time import sleep
import wx.grid as gridlib
import sys
import Tkinter
from Tkinter import *

I have tryed from igraph import Graph but it would still look for that TEXTTABLE.

I've tried using py2exe, cx freeze and also the nice Gui interface to them GUI2exe. No luck. Same Error whatever I try.

I'm sorry if the solution is obvious. I'm not a pro. Any help is much appreciated!


Solution

  • igraph is importing texttable dynamically, so the freezing tools don't know that they need to copy the module in.

    In cx_Freeze, you could add igraph.vendor to 'packages' (see the docs) to force it to copy everything from that package. There's probably a similar option for py2exe.

    Alternatively, if you put import igraph.vendor.texttable somewhere in the code, the freezing tools will pick that up and know to include it.