Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9048797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T12:14:25+00:00 2026-06-16T12:14:25+00:00

So I have a GUI program that has a great deal of stuff going

  • 0

So I have a GUI program that has a great deal of “stuff” going on. I am adding a python scripting interface so someone can interact problematically with this environment. I am using boost python. So first thing I have is a new module I want to create. For simplicity right now my module just is hello world…

#include <boost/python.hpp>                                                     

char const* greet() {                                                           
   return "hello, world" ;                                                      
}                                                                               

BOOST_PYTHON_MODULE(cerrnimapi) {                                               
  boost::python::def( "greet", greet ) ;                                        
}  

In my system I have a class that looks like this…

Controller::Controller( ) {         
  Py_Initialize( ) ;                                                            

  main_module = boost::python::import( "__main__" ) ;                           
  main_namespace = main_module.attr( "__dict__" ) ;                             
}                                                                                                                                                     

void Controller::execute_script( std::string filename ) {                       
  try {                                                                         
    boost::python::api::object ignored =                                        
      boost::python::exec_file( filename.c_str(), main_namespace ) ;            
  } catch( boost::python::error_already_set const & ) {                         
    if (PyErr_ExceptionMatches(PyExc_ZeroDivisionError)) {                      
    } else {                                                                    
        PyErr_Print();                                                          
    }                                                                           
  }                                                                             
}

Now when I go to execute the script in the GUI I get an error…

Traceback (most recent call last):
  File "/home/mokon/repository/trunk/python.py", line 1, in <module>
    import cerrnimapi
ImportError: No module named cerrnimapi

So of course I am building something wrong. My build system uses autotools so here are a few pieces of that build system that relate to this…

In configure.ac:

AM_PATH_PYTHON                                                                  
AC_ARG_VAR([PYTHON_INCLUDE], [Include flags for python, bypassing python-config])
AC_ARG_VAR([PYTHON_CONFIG], [Path to python-config])                            
AS_IF([test -z "$PYTHON_INCLUDE"], [                                            
  AS_IF([test -z "$PYTHON_CONFIG"], [                                           
    AC_PATH_PROGS([PYTHON_CONFIG],                                              
                  [python$PYTHON_VERSION-config python-config],                 
                  [no],                                                         
                  [`dirname $PYTHON`])                                          
    AS_IF([test "$PYTHON_CONFIG" = no], [AC_MSG_ERROR([cannot find python-config for $PYTHON.])])
  ])                                                                            
  AC_MSG_CHECKING([python include flags])                                       
  PYTHON_INCLUDE=`$PYTHON_CONFIG --includes`                                    
  AC_MSG_RESULT([$PYTHON_INCLUDE])                                              
])                                                                              

AC_ARG_VAR([PYTHON_LD], [Linker flags for python, bypassing python-config])     
AS_IF([test -z "$PYTHON_LD"], [                                                 
  AS_IF([test -z "$PYTHON_CONFIG"], [                                           
    AC_PATH_PROGS([PYTHON_CONFIG],                                              
                  [python$PYTHON_VERSION-config python-config],                 
                  [no],                                                         
                  [`dirname $PYTHON`])                                          
    AS_IF([test "$PYTHON_CONFIG" = no], [AC_MSG_ERROR([cannot find python-config for $PYTHON.])])
  ])                                                                            
  AC_MSG_CHECKING([python linker flags])                                        
  PYTHON_LD=`$PYTHON_CONFIG --ldflags`                                          
  AC_MSG_RESULT([$PYTHON_LD])                                                   
]) 

In my obj/ dir Makefile.am…

pyexec_LTLIBRARIES = cerrnimapi.la                                              
cerrnimapi_la_SOURCES = ${SRC_DIR}/lib/PythonAPI.cpp                            
cerrnimapi_la_LDFLAGS = -avoid-version -module $(PYTHON_LD)                     
cerrnimapi_la_CXXFLAGS = $(PYTHON_INCLUDE)  

My makefile builds the shared lib and its in the obj folder along with my main program. This doesn’t help. I have also done a make install to install the cerrnimapi lib in the python folders. This doesn’t help.

I have also tried adding the PythonAPI.cpp to my main programs SOURCES but to no avail.

Any ideas? let me know what additional information would be helpful.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T12:14:27+00:00Added an answer on June 16, 2026 at 12:14 pm

    Some things to check:

    • Run nm over your .so file (which might be in .libs) to make sure your module init func is exported.
    • Make your program print out the value of sys.path (use PyRun_SimpleString) to see where it’s expecting your module to turn up. If you’re defining modules for your interpreter only, you probably don’t want to install them in $pyexecdir.
    • Read the Extending Embedded Python article. You don’t really need to build dynamic libraries at all, unless you’re trying for a plugin architecture.

    A point on style: You should try and find $PYTHON_CONFIG outside of your tests for $PYTHON_INCLUDE and $PYTHON_LD so you’re not doing the AC_PATH_PROGS twice:

    AM_PATH_PYTHON                                                                  
    AC_ARG_VAR([PYTHON_CONFIG], [Path to python-config])                            
    AS_IF([test -z "$PYTHON_CONFIG"], [                                           
      AC_PATH_PROGS([PYTHON_CONFIG],                                              
                    [python$PYTHON_VERSION-config python-config],                 
                    [no],                                                         
                    [`dirname $PYTHON`])                                          
    ])                                                                            
    
    AC_ARG_VAR([PYTHON_INCLUDE], [Include flags for python, bypassing python-config])
    AS_IF([test -z "$PYTHON_INCLUDE"], [                                            
      AC_MSG_CHECKING([python include flags])                                       
      AS_IF([test "$PYTHON_CONFIG" = no], [AC_MSG_ERROR([cannot find python-config for $PYTHON.])])
      PYTHON_INCLUDE=`$PYTHON_CONFIG --includes`                                    
      AC_MSG_RESULT([$PYTHON_INCLUDE])                                              
    ])                                                                              
    
    AC_ARG_VAR([PYTHON_LD], [Linker flags for python, bypassing python-config])     
    AS_IF([test -z "$PYTHON_LD"], [                                                 
      AC_MSG_CHECKING([python linker flags])                                        
      AS_IF([test "$PYTHON_CONFIG" = no], [AC_MSG_ERROR([cannot find python-config for $PYTHON.])])
      PYTHON_LD=`$PYTHON_CONFIG --ldflags`                                          
      AC_MSG_RESULT([$PYTHON_LD])                                                   
    ])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a program that (amongst other things) has a command line interface that
basically, I have a program that has a class to create a basic GUI,
I have a Perl program that has a GTK2 GUI (via the Gtk2 package).
I have a GUI program , that has a QLocalServer inside , each time
I have a Windows program that has a GUI which also uses a command
I have a program that has Classes GUI Upload and a buffer between the
I have written a java program that is actually works as a gui to
I have a program with a GUI interface whose initial set-up I need to
I have a GUI that is going to do a lot of disparate tasks.
I have a vb.net 2.0 program, that has a batch/queue routine to execute tasks

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.