wxPyCoreAPI_IMPORT returns false

Hi,

my problem is that executing the embedded python sample provided with
http://downloads.sourceforge.net/wxpython/wxPython-demo-2.8.10.1.tar.bz2
on winXP results in wxPyCoreAPI_IMPORT returning false. I know there
is a thread about the same problem from Mike Porter. But this solution
using prebuilded python/wxPython libraries is not an option for me.

First I should mention that I do not have any libraries installed
(python/wxPython). I builded the python2.6.5 library by myself in
debug and release. The reason is that I have a Visual Studio 2008 SP1.
The standard python-2.6 libraries are build with Visual Studio 2008
without SP1. Using standard python-2.6 interpreter in my application
would result in a version mismatch of Visual Studio DLLs (msvcm90.dll,
msvcp90.dll and msvcr90.dll).

Having compiled python2.6.5 I builded wxPython2.8.10.1 myself as it
was described here (http://www.wxpython.org/BUILD.html). I builded the
debug version with (no unicode):
'nmake -f makefile.vc OFFICIAL_BUILD=1 SHARED=1 MONOLITHIC=0
USE_OPENGL=1 USE_GDIPLUS=1 BUILD=debug'

I builded the release version with:
'nmake -f makefile.vc OFFICIAL_BUILD=1 SHARED=1 MONOLITHIC=0
USE_OPENGL=1 USE_GDIPLUS=1 DEBUG_FLAG=1 CXXFLAGS=/D__NO_VC_CRTDBG__
WXDEBUGFLAG=h BUILD=release'

Afterwards I used python to build python part of wxPython:
'python setup.py build_ext --inplace MONOLITHIC=0 UNICODE=0
BUILD_GLCANVAS=0 BUILD_STC=0 BUILD_GIZMOS=0

Then I builded the embedded sample from wxPython-demos. First I had to
change the python version from 2.5 to 2.6 in makefile.vc. Additionally
I needed to replace the monolithic wx library by multifile wx library
files in the LIBS section of makefile.vc. Afterwards the embedded
sample compiled. Note: this example uses the debug version of wxPython/
python.

Now I am stuck with wxPyCoreAPI_IMPORT in embedded.cpp (http://
downloads.sourceforge.net/wxpython/wxPython-demo-2.8.10.1.tar.bz2)
returning false.

Is there any way to get this example working in windows. In Ubuntu
10.04 running this example is no problem at all (debug and release). I
need to get this example running in windows because I want to
integrate this method in another wxWidgets windows application.

Hagen

···

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

This likely means that the import failed to find or load the extension module for some reason. You may want to trace into the Python APIs with the debugger to see what is going on.

···

On 5/4/10 8:21 AM, Hagen Mölle wrote:

Now I am stuck with wxPyCoreAPI_IMPORT in embedded.cpp (http://
downloads.sourceforge.net/wxpython/wxPython-demo-2.8.10.1.tar.bz2)
returning false.

--
Robin Dunn
Software Craftsman

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

Sorry, in my description building the python part of wxPython is a
typo. I used:
'python setup.py build_ext --inplace --debug MONOLITHIC=0 UNICODE=0
BUILD_GLCANVAS=0 BUILD_STC=0 BUILD_GIZMOS=0'

···

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

Hi Robin,

First I like to make a proposal. In the embedded sample code we should
add the following code which enables console output. This makes
debugging a lot easier.

1. some includes

#if WIN32
  #include <windows.h>
  #include <stdio.h>
  #include <fcntl.h>
  #include <io.h>
  #include <iostream>
  #include <fstream>

  #ifndef _USE_OLD_IOSTREAMS
  using namespace std;
  #endif

  // maximum mumber of lines the output console should have
  static const WORD MAX_CONSOLE_LINES = 500;
#endif

2. In private section of MyApp:

#if WIN32
    void RedirectIOToConsole();
#endif

3. In MyApp methods section

#if WIN32
void MyApp::RedirectIOToConsole()
{
  #ifdef _DEBUG
  int hConHandle;
  long lStdHandle;
  CONSOLE_SCREEN_BUFFER_INFO coninfo;
  FILE *fp;

  // allocate a console for this app
  AllocConsole();

  // set the screen buffer to be big enough to let us scroll text
  GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE),
&coninfo);
  coninfo.dwSize.Y = MAX_CONSOLE_LINES;
  SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE),
coninfo.dwSize);

  // redirect unbuffered STDOUT to the console
  lStdHandle = (long)GetStdHandle(STD_OUTPUT_HANDLE);
  hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
  fp = _fdopen( hConHandle, "w" );
  *stdout = *fp;
  setvbuf( stdout, NULL, _IONBF, 0 );

  // redirect unbuffered STDIN to the console
  lStdHandle = (long)GetStdHandle(STD_INPUT_HANDLE);
  hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
  fp = _fdopen( hConHandle, "r" );
  *stdin = *fp;
  setvbuf( stdin, NULL, _IONBF, 0 );

  // redirect unbuffered STDERR to the console
  lStdHandle = (long)GetStdHandle(STD_ERROR_HANDLE);
  hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
  fp = _fdopen( hConHandle, "w" );
  *stderr = *fp;
  setvbuf( stderr, NULL, _IONBF, 0 );

  // make cout, wcout, cin, wcin, wcerr, cerr, wclog and clog
  // point to console as well
  ios::sync_with_stdio();
  #endif
}
#endif

4. First lines in bool MyApp::OnInit():

#if WIN32
  RedirectIOToConsole();
#endif

···

On May 5, 6:42 am, Robin Dunn <ro...@alldunn.com> wrote:

On 5/4/10 8:21 AM, Hagen Mölle wrote:

> Now I am stuck with wxPyCoreAPI_IMPORT in embedded.cpp (http://
> downloads.sourceforge.net/wxpython/wxPython-demo-2.8.10.1.tar.bz2)
> returning false.

This likely means that the import failed to find or load the extension
module for some reason. You may want to trace into the Python APIs with
the debugger to see what is going on.

--
Robin Dunn
Software Craftsmanhttp://wxPython.org

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visithttp://groups.google.com/group/wxPython-users?hl=en

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

Hi Robin,

After enabling console output I was able to track down my error. The
python api was missing. So copying it to the app dir my application
starts.

But now the message window (wxPython: stdout/stderr) tells me that
the application can not find module named _stc. Ok, this is easy. I
disabled the building the _stc module during building the python part
of wxPython:

'python setup.py build_ext --inplace --debug MONOLITHIC=0 UNICODE=0
BUILD_GLCANVAS=0 BUILD_STC=0 BUILD_GIZMOS=0'

Using BUILD_STC=1 results in an error during linking of _stc module.
It says it can not find wxmsw28d_stc.lib. I searched wxPython dir for
this library. I figured out it was not build. So my question is how to
enable the build of wxmsw28d_stc.lib. The is nothing mentioned in the
setup.h file how to enable the building of wxmsw28d_stc.lib.

Thanks for your help,

Hagen

···

On May 5, 6:42 am, Robin Dunn <ro...@alldunn.com> wrote:

On 5/4/10 8:21 AM, Hagen Mölle wrote:

> Now I am stuck with wxPyCoreAPI_IMPORT in embedded.cpp (http://
> downloads.sourceforge.net/wxpython/wxPython-demo-2.8.10.1.tar.bz2)
> returning false.

This likely means that the import failed to find or load the extension
module for some reason. You may want to trace into the Python APIs with
the debugger to see what is going on.

--
Robin Dunn
Software Craftsmanhttp://wxPython.org

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visithttp://groups.google.com/group/wxPython-users?hl=en

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

Hi Robin,

in the end I could execute the embedded sample without problems. May I
contribute my experience to wxPython users. I probably can make a
walkthrough for unexperienced users. So they can build their
application in fully featured debug mode too.

Hagen

···

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

Adding some pages for this in the wiki would be good.

···

On 5/5/10 4:16 AM, Hagen Mölle wrote:

Hi Robin,

in the end I could execute the embedded sample without problems. May I
contribute my experience to wxPython users. I probably can make a
walkthrough for unexperienced users. So they can build their
application in fully featured debug mode too.

--
Robin Dunn
Software Craftsman

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

Please submit these changes as a patch file. See wxTrac has been migrated to GitHub Issues - wxWidgets if you don't know how to make a patch file.

···

On 5/4/10 10:52 PM, Hagen Mölle wrote:

Hi Robin,

First I like to make a proposal. In the embedded sample code we should
add the following code which enables console output. This makes
debugging a lot easier.

--
Robin Dunn
Software Craftsman

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

You also need to build the stc contrib in wxWidgits.

···

On 5/4/10 11:05 PM, Hagen Mölle wrote:

Using BUILD_STC=1 results in an error during linking of _stc module.
It says it can not find wxmsw28d_stc.lib. I searched wxPython dir for
this library. I figured out it was not build. So my question is how to
enable the build of wxmsw28d_stc.lib. The is nothing mentioned in the
setup.h file how to enable the building of wxmsw28d_stc.lib.

--
Robin Dunn
Software Craftsman

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

Once the pages are added, please post a link here so the rest of us
can take a quick look too!

···

On May 5, 10:29 am, Robin Dunn <ro...@alldunn.com> wrote:

On 5/5/10 4:16 AM, Hagen Mölle wrote:

> Hi Robin,

> in the end I could execute the embedded sample without problems. May I
> contribute my experience to wxPython users. I probably can make a
> walkthrough for unexperienced users. So they can build their
> application in fully featured debug mode too.

Adding some pages for this in the wiki would be good.

--
Robin Dunn
Software Craftsmanhttp://wxPython.org

-------------------
Mike Driscoll

Blog: http://blog.pythonlibrary.org

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en