AttributeError on module import
Bug reports:
A strange bug is happening when I import the graph_tool module version 2.31 in python 2.7.
-
Are you running the latest graph-tool
version? -
Did you compile graph-tool
manually? -
If you answered yes above, did you use the exact same compiler to build graph-tool
,boost-python
andPython
?
Problem
The command python2.7 -c 'import graph_tool; print graph_tool'
works and print the right path
but this one: python2.7 -c 'from graph_tool import search'
fails with
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/opt/test/lib/python2.7/site-packages/graph_tool/search/__init__.py", line 86, in <module>
dl_import("from . import libgraph_tool_search")
File "/opt/test/lib/python2.7/site-packages/graph_tool/dl_import.py", line 61, in dl_import
exec(import_expr, local_dict, global_dict)
File "<string>", line 1, in <module>
AttributeError: 'NoneType' object has no attribute '__dict__'
Many submodules trigger this exact same error: spectral, topology, search, draw, generation, stats, flow, clustering, inference, centrality. Other submodules such as collection, util and correlations can be imported without any problem.
The dynamic submodule fails on a python 3 only feature (for our project we can only use python 2.7):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/opt/test/lib/python2.7/site-packages/graph_tool/dynamics/__init__.py", line 182
self.make_state = lambda *args: make_state(*args, weighted, constant_beta)
SyntaxError: only named arguments may follow *expression
but this one is easy to fix manually.
I have no idea how to debug the AttributeError thrown from within a python 'exec'. Could you provide me some hints on where to look ?
How was the module built ?
The sources are from https://downloads.skewed.de/graph-tool/graph-tool-2.31.tar.bz2. It has been built within a fresh debian docker image by using bootstrapped gcc 9.3.
All dependencies were built with the exact same compiler:
- shared python 2.7.17
- shared boost 1.72.0
- static CGAL 5.0.2
- sparsehash 2.0.3
Build command:
CFLAGS="-I${PREFIX}/include" LDFLAGS="-L${PREFIX}/lib" ./configure --prefix="${PREFIX}" --disable-cairo --with-cgal="${PREFIX}" --with-boost="${PREFIX}" && make && make install
I will try to provide a minimal Dockerfile to reproduce this error as soon as possible.