ImportError (PyInit) on fresh installations

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

ImportError (PyInit) on fresh installations

Andrea Bianco
Dear All,

I have a SWIG python C++ project that works well on an Ubuntu 14.04, I tried to make it work on Mac Os and Ubuntu 16.06 (fresh installations) and I get this error: "ImportError: dynamic module does not define module export function (PyInit_)”

this is the relevant portion of the CMakeList file:

find_package(SWIG 3.0.10 REQUIRED)
include(${SWIG_USE_FILE}) 
find_package(PythonLibs)

include_directories(${PYTHON_INCLUDE_PATH} 

${CMAKE_CURRENT_SOURCE_DIR}/include 

 ${CPP_SOURCE_FILES}/LpList.cpp

)

set_property(SOURCE ${SWIG_PROJECTS_DIR}/DMMaker.i PROPERTY CPLUSPLUS ON) 

set_property(SOURCE ${SWIG_PROJECTS_DIR}/DMMaker.i PROPERTY SWIG_FLAG "-includeall" "-py3" "-builtin" "-externative")

swig_add_module(DMMaker python ${SWIG_PROJECTS_DIR}/DMMaker.i ${CPP_SOURCE_FILES}/DMMaker.cpp )

swig_link_libraries(DMMaker LpList ${PYTHON_LIBRARIES})


this the full error message form that i get:

dm@asus:~/Src/DMMaker/release$ python3 ../py/script.py 

Traceback (most recent call last): File "/home/dm/Src/DMMaker/release/DMMaker.py", line 18, in swig_import_helper return importlib.import_module(mname) File "/usr/lib/python3.5/importlib/init.py", line 126, in import_module return bootstrap.gcd_import(name[level:], package, level) File "", line 986, in gcd_import File "<frozen importlib.bootstrap>", line 969, in _findand_load File "", line 958, in find_and_load_unlocked File "<frozen importlib.bootstrap>", line 666, in _loadunlocked File "", line 577, in module_from_spec File "", line 906, in create_module File "", line 222, in call_with_frames_removed ImportError: dynamic module does not define module export function (PyInit_DMMaker)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "../py/script.py", line 5, in import DMMaker 

File "/home/dm/Src/DMMaker/release/DMMaker.py", line 21, in DMMaker = swig_import_helper() 

File "/home/dm/Src/DMMaker/release/DMMaker.py", line 20, in swig_import_helper return importlib.import_module('_DMMaker') File "/usr/lib/python3.5/importlib/init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) 

ImportError: dynamic module does not define module export function (PyInit_DMMaker)


my DMMaker.i file is 

%module DMMaker 

%include "std_string.i” 

%{ #include "DMMaker.h" %} 

%include "DMMaker.h"


in ~/Src/DMMaker/release I have _DMMaker.so , DMMaker.py, DMMakerPYTHON_wrap.cxx and libLpList.so . Everything looks fine to me, I cannot understand the problem. Do you have any clue?
Thanks in advance,
Andrea






------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Swig-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/swig-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ImportError (PyInit) on fresh installations

Andrea Bianco
Dear All, 

I solved the issue on ubuntu installing the package python3-dev . I still have the same problem on Mac OsX, where I installed python with brew install python3. 

Anyway, I compiled SWIG from scratch, and i didn’t see any warning in the ./configure process.

Bests,
Andrea

On 15 Dec 2016, at 16:47, Andrea Bianco <[hidden email]> wrote:

Dear All,

I have a SWIG python C++ project that works well on an Ubuntu 14.04, I tried to make it work on Mac Os and Ubuntu 16.06 (fresh installations) and I get this error: "ImportError: dynamic module does not define module export function (PyInit_)”

this is the relevant portion of the CMakeList file:

find_package(SWIG 3.0.10 REQUIRED)
include(${SWIG_USE_FILE}) 
find_package(PythonLibs)

include_directories(${PYTHON_INCLUDE_PATH} 

${CMAKE_CURRENT_SOURCE_DIR}/include 

 ${CPP_SOURCE_FILES}/LpList.cpp

)

set_property(SOURCE ${SWIG_PROJECTS_DIR}/DMMaker.i PROPERTY CPLUSPLUS ON) 

set_property(SOURCE ${SWIG_PROJECTS_DIR}/DMMaker.i PROPERTY SWIG_FLAG "-includeall" "-py3" "-builtin" "-externative")

swig_add_module(DMMaker python ${SWIG_PROJECTS_DIR}/DMMaker.i ${CPP_SOURCE_FILES}/DMMaker.cpp )

swig_link_libraries(DMMaker LpList ${PYTHON_LIBRARIES})


this the full error message form that i get:

dm@asus:~/Src/DMMaker/release$ python3 ../py/script.py 

Traceback (most recent call last): File "/home/dm/Src/DMMaker/release/DMMaker.py", line 18, in swig_import_helper return importlib.import_module(mname) File "/usr/lib/python3.5/importlib/init.py", line 126, in import_module return bootstrap.gcd_import(name[level:], package, level) File "", line 986, in gcd_import File "<frozen importlib.bootstrap>", line 969, in _findand_load File "", line 958, in find_and_load_unlocked File "<frozen importlib.bootstrap>", line 666, in _loadunlocked File "", line 577, in module_from_spec File "", line 906, in create_module File "", line 222, in call_with_frames_removed ImportError: dynamic module does not define module export function (PyInit_DMMaker)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "../py/script.py", line 5, in import DMMaker 

File "/home/dm/Src/DMMaker/release/DMMaker.py", line 21, in DMMaker = swig_import_helper() 

File "/home/dm/Src/DMMaker/release/DMMaker.py", line 20, in swig_import_helper return importlib.import_module('_DMMaker') File "/usr/lib/python3.5/importlib/init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) 

ImportError: dynamic module does not define module export function (PyInit_DMMaker)


my DMMaker.i file is 

%module DMMaker 

%include "std_string.i” 

%{ #include "DMMaker.h" %} 

%include "DMMaker.h"


in ~/Src/DMMaker/release I have _DMMaker.so , DMMaker.py, DMMakerPYTHON_wrap.cxx and libLpList.so . Everything looks fine to me, I cannot understand the problem. Do you have any clue?
Thanks in advance,
Andrea





------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot_______________________________________________
Swig-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/swig-user


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Swig-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/swig-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ImportError (PyInit) on fresh installations

Andrea Bianco
Dear All,

Solved also for mac os x. Apparently the Cmake FindPythonLibs.cmake has a bug https://itk.org/Bug/view.php?id=14809 for versions below 3.4, and loads only the python2.7 libraries even if you have also python3 installed.

upgrading to cmake 3.6 solved the issue.

Bests,
Andrea
On 16 Dec 2016, at 11:48, Andrea Bianco <[hidden email]> wrote:

Dear All, 

I solved the issue on ubuntu installing the package python3-dev . I still have the same problem on Mac OsX, where I installed python with brew install python3. 

Anyway, I compiled SWIG from scratch, and i didn’t see any warning in the ./configure process.

Bests,
Andrea

On 15 Dec 2016, at 16:47, Andrea Bianco <[hidden email]> wrote:

Dear All,

I have a SWIG python C++ project that works well on an Ubuntu 14.04, I tried to make it work on Mac Os and Ubuntu 16.06 (fresh installations) and I get this error: "ImportError: dynamic module does not define module export function (PyInit_)”

this is the relevant portion of the CMakeList file:

find_package(SWIG 3.0.10 REQUIRED)
include(${SWIG_USE_FILE}) 
find_package(PythonLibs)

include_directories(${PYTHON_INCLUDE_PATH} 

${CMAKE_CURRENT_SOURCE_DIR}/include 

 ${CPP_SOURCE_FILES}/LpList.cpp

)

set_property(SOURCE ${SWIG_PROJECTS_DIR}/DMMaker.i PROPERTY CPLUSPLUS ON) 

set_property(SOURCE ${SWIG_PROJECTS_DIR}/DMMaker.i PROPERTY SWIG_FLAG "-includeall" "-py3" "-builtin" "-externative")

swig_add_module(DMMaker python ${SWIG_PROJECTS_DIR}/DMMaker.i ${CPP_SOURCE_FILES}/DMMaker.cpp )

swig_link_libraries(DMMaker LpList ${PYTHON_LIBRARIES})


this the full error message form that i get:

dm@asus:~/Src/DMMaker/release$ python3 ../py/script.py 

Traceback (most recent call last): File "/home/dm/Src/DMMaker/release/DMMaker.py", line 18, in swig_import_helper return importlib.import_module(mname) File "/usr/lib/python3.5/importlib/init.py", line 126, in import_module return bootstrap.gcd_import(name[level:], package, level) File "", line 986, in gcd_import File "<frozen importlib.bootstrap>", line 969, in _findand_load File "", line 958, in find_and_load_unlocked File "<frozen importlib.bootstrap>", line 666, in _loadunlocked File "", line 577, in module_from_spec File "", line 906, in create_module File "", line 222, in call_with_frames_removed ImportError: dynamic module does not define module export function (PyInit_DMMaker)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "../py/script.py", line 5, in import DMMaker 

File "/home/dm/Src/DMMaker/release/DMMaker.py", line 21, in DMMaker = swig_import_helper() 

File "/home/dm/Src/DMMaker/release/DMMaker.py", line 20, in swig_import_helper return importlib.import_module('_DMMaker') File "/usr/lib/python3.5/importlib/init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) 

ImportError: dynamic module does not define module export function (PyInit_DMMaker)


my DMMaker.i file is 

%module DMMaker 

%include "std_string.i” 

%{ #include "DMMaker.h" %} 

%include "DMMaker.h"


in ~/Src/DMMaker/release I have _DMMaker.so , DMMaker.py, DMMakerPYTHON_wrap.cxx and libLpList.so . Everything looks fine to me, I cannot understand the problem. Do you have any clue?
Thanks in advance,
Andrea





------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot_______________________________________________
Swig-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/swig-user

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot_______________________________________________
Swig-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/swig-user


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Swig-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/swig-user
Loading...