ImportError: cannot import name myole4ax (py2exe + wx.lib.flashwin + Python 2.7 + wxPython 2.8.11 + comtypes)

Hi Freinds,

I try to build a sample using ActiveX app (like Flash window). I have
following components installed on my windows machine:

py2exe + wx.lib.flashwin + Python 2.7 + wxPython 2.8.11 + comtypes

When I execute it using "python.exe testActivex.py" it works fine and
I'm able to open flash file. So, I tried to generate exe using py2exe
but I got the following error:

18:57:22: Debug: src/helpers.cpp(140): 'CreateActCtx' failed with
error 0x0000007b (the filename, directory name, or volume label syntax
is incorrect.).
Traceback (most recent call last):
  File "testflv.py", line 27, in <module>
  File "zipextimporter.pyo", line 82, in load_module
  File "wx\lib\flashwin.pyo", line 15, in <module>
  File "zipextimporter.pyo", line 82, in load_module
  File "wx\lib\activex.pyo", line 44, in <module>
ImportError: cannot import name myole4ax

I have been digging about this since last two days. I've tried to read
whatever I can from comtypes.gen to activex to sys.frozen attributes.
I have also read that myole4ax.tlb was missing in some of the wxPython
versions(can't believe). After spending this much time I'm not able to
resolve the issue.

Is there anything wrong with my setup.py. I tried with bundled files =
3 and 1. My goal is to create one exe only. (i.e. bundled file = 1)

It would be really great if any of you gurus can help me out and point
me to the right direction.

Thanks a ton in advance.

Make sure you run the wxPython Demo, go to the ActiveX_Flashwindow
demo and play yourself some Asteroids.

Once you get tired of that, go back and "recompile" your code.

You'll find that it works just fine now.

Don't ask me why this error happens, but it's been a "bug" for a few
wxPython versions now.

BTW...when you have a moment, you should check out cx_freeze. It is
an order of a magnitude easier to use, and is better maintained.

Chris.

···

On Thu, 18 Nov 2010 19:09:15 -0800 (PST), Humble Learner <navasia@gmail.com> wrote:

Hi Freinds,

I try to build a sample using ActiveX app (like Flash window). I have
following components installed on my windows machine:

py2exe + wx.lib.flashwin + Python 2.7 + wxPython 2.8.11 + comtypes

When I execute it using "python.exe testActivex.py" it works fine and
I'm able to open flash file. So, I tried to generate exe using py2exe
but I got the following error:

18:57:22: Debug: src/helpers.cpp(140): 'CreateActCtx' failed with
error 0x0000007b (the filename, directory name, or volume label syntax
is incorrect.).
Traceback (most recent call last):
File "testflv.py", line 27, in <module>
File "zipextimporter.pyo", line 82, in load_module
File "wx\lib\flashwin.pyo", line 15, in <module>
File "zipextimporter.pyo", line 82, in load_module
File "wx\lib\activex.pyo", line 44, in <module>
ImportError: cannot import name myole4ax

I have been digging about this since last two days. I've tried to read
whatever I can from comtypes.gen to activex to sys.frozen attributes.
I have also read that myole4ax.tlb was missing in some of the wxPython
versions(can't believe). After spending this much time I'm not able to
resolve the issue.

Is there anything wrong with my setup.py. I tried with bundled files =
3 and 1. My goal is to create one exe only. (i.e. bundled file = 1)

It would be really great if any of you gurus can help me out and point
me to the right direction.

Thanks a ton in advance.

Hi Freinds,

I try to build a sample using ActiveX app (like Flash window). I have
following components installed on my windows machine:

py2exe + wx.lib.flashwin + Python 2.7 + wxPython 2.8.11 + comtypes

When I execute it using "python.exe testActivex.py" it works fine and
I'm able to open flash file. So, I tried to generate exe using py2exe
but I got the following error:

18:57:22: Debug: src/helpers.cpp(140): 'CreateActCtx' failed with
error 0x0000007b (the filename, directory name, or volume label syntax
is incorrect.).
Traceback (most recent call last):
   File "testflv.py", line 27, in<module>
   File "zipextimporter.pyo", line 82, in load_module
   File "wx\lib\flashwin.pyo", line 15, in<module>
   File "zipextimporter.pyo", line 82, in load_module
   File "wx\lib\activex.pyo", line 44, in<module>
ImportError: cannot import name myole4ax

I have been digging about this since last two days. I've tried to read
whatever I can from comtypes.gen to activex to sys.frozen attributes.
I have also read that myole4ax.tlb was missing in some of the wxPython
versions(can't believe). After spending this much time I'm not able to
resolve the issue.

Here's the code in question:

import sys, os
if not hasattr(sys, 'frozen'):
     f = os.path.join(os.path.dirname(__file__), 'myole4ax.tlb')
     cc.GetModule(f)
from comtypes.gen import myole4ax

The intent is that when the app is running in a non-frozen state (IOW, without py2exe) then it will load the activex component from the same location as activex.py and comtypes will make a module for it in comtypes.gen. When it is running from a frozen app (IOW in a py2ex'd form) then it will just import from comtypes.gen and skip the rest. So basically you need to run the application from source before you can bundle it up with py2exe.

Is there anything wrong with my setup.py. I tried with bundled files =
3 and 1. My goal is to create one exe only. (i.e. bundled file = 1)

You probably won't be able to do that. Things have been reported to work much better in an unbundled state. You can instead use one of the free installer builders to bundle your files into the single .exe that your users can run to install the collection of files.

···

On 11/18/10 7:09 PM, Humble Learner wrote:

--
Robin Dunn
Software Craftsman

I tried what has been recommended by Chris but no luck!!!

Just want to confirm that is it really work in that way? If not then
is there any way to pack falshwindow in py2exe? any workaround? I've
spent so many days on it. :frowning:

···

On Nov 18, 8:35 pm, Robin Dunn <ro...@alldunn.com> wrote:

On 11/18/10 7:09 PM, Humble Learner wrote:

> Hi Freinds,

> I try to build a sample using ActiveX app (like Flash window). I have
> following components installed on my windows machine:

> py2exe + wx.lib.flashwin + Python 2.7 + wxPython 2.8.11 + comtypes

> When I execute it using "python.exe testActivex.py" it works fine and
> I'm able to open flash file. So, I tried to generate exe using py2exe
> but I got the following error:

> 18:57:22: Debug: src/helpers.cpp(140): 'CreateActCtx' failed with
> error 0x0000007b (the filename, directory name, or volume label syntax
> is incorrect.).
> Traceback (most recent call last):
> File "testflv.py", line 27, in<module>
> File "zipextimporter.pyo", line 82, in load_module
> File "wx\lib\flashwin.pyo", line 15, in<module>
> File "zipextimporter.pyo", line 82, in load_module
> File "wx\lib\activex.pyo", line 44, in<module>
> ImportError: cannot import name myole4ax

> I have been digging about this since last two days. I've tried to read
> whatever I can from comtypes.gen to activex to sys.frozen attributes.
> I have also read that myole4ax.tlb was missing in some of the wxPython
> versions(can't believe). After spending this much time I'm not able to
> resolve the issue.

Here's the code in question:

import sys, os
if not hasattr(sys, 'frozen'):
f = os.path.join(os.path.dirname(__file__), 'myole4ax.tlb')
cc.GetModule(f)
from comtypes.gen import myole4ax

The intent is that when the app is running in a non-frozen state (IOW,
without py2exe) then it will load the activex component from the same
location as activex.py and comtypes will make a module for it in
comtypes.gen. When it is running from a frozen app (IOW in a py2ex'd
form) then it will just import from comtypes.gen and skip the rest. So
basically you need to run the application from source before you can
bundle it up with py2exe.

> Is there anything wrong with my setup.py. I tried with bundled files =
> 3 and 1. My goal is to create one exe only. (i.e. bundled file = 1)

You probably won't be able to do that. Things have been reported to
work much better in an unbundled state. You can instead use one of the
free installer builders to bundle your files into the single .exe that
your users can run to install the collection of files.

--
Robin Dunn
Software Craftsmanhttp://wxPython.org- Hide quoted text -

- Show quoted text -

I would be shocked if my technique, if used correctly, doesn't work. I
have a program that makes extensive use of the ActiveX Flash wrapper,
and that technique ALWAYS works, and I can bundle just fine.

Do you have these files:
myole4ax.idl
myole4ax.tlb

On the path:
<drive:Python install directory>\Lib\site-packages\wx-2.9.1-msw\wx\lib

If you don't, then you haven't run the wxPython Demo and played
asteroids.

If you have, these files will be picked up by py2exe.

I have had the line "bundle_files" commented out for YEARS, but put it
into the "Setup" function of your py2exe script:

setup(
    options = {"py2exe": {"compressed": 1,
                          "optimize": 2,
                          "ascii": 1,
                          "bundle_files": 3,
                          "packages": ["encodings"],
                          "includes": ["decimal","shlex","os"],
                          }
              },
    zipfile = None,
# console = [program],
    bundle_files = [
(r"wx/lib",[r"C:\Python27\Lib\site-packages\wx-2.9.1-msw\wx\lib\myole4ax.idl",r"C:\Python275\Lib\site-packages\wx-2.9.1-msw\wx\lib\myole4ax.tlb"])
]
    windows = [program],
    )

See if that works.

Chris.

···

On Thu, 18 Nov 2010 20:45:59 -0800 (PST), Humble Learner <navasia@gmail.com> wrote:

I tried what has been recommended by Chris but no luck!!!

Just want to confirm that is it really work in that way? If not then
is there any way to pack falshwindow in py2exe? any workaround? I've
spent so many days on it. :frowning:

On Nov 18, 8:35 pm, Robin Dunn <ro...@alldunn.com> wrote:

On 11/18/10 7:09 PM, Humble Learner wrote:

> Hi Freinds,

> I try to build a sample using ActiveX app (like Flash window). I have
> following components installed on my windows machine:

> py2exe + wx.lib.flashwin + Python 2.7 + wxPython 2.8.11 + comtypes

> When I execute it using "python.exe testActivex.py" it works fine and
> I'm able to open flash file. So, I tried to generate exe using py2exe
> but I got the following error:

> 18:57:22: Debug: src/helpers.cpp(140): 'CreateActCtx' failed with
> error 0x0000007b (the filename, directory name, or volume label syntax
> is incorrect.).
> Traceback (most recent call last):
> File "testflv.py", line 27, in<module>
> File "zipextimporter.pyo", line 82, in load_module
> File "wx\lib\flashwin.pyo", line 15, in<module>
> File "zipextimporter.pyo", line 82, in load_module
> File "wx\lib\activex.pyo", line 44, in<module>
> ImportError: cannot import name myole4ax

> I have been digging about this since last two days. I've tried to read
> whatever I can from comtypes.gen to activex to sys.frozen attributes.
> I have also read that myole4ax.tlb was missing in some of the wxPython
> versions(can't believe). After spending this much time I'm not able to
> resolve the issue.

Here's the code in question:

import sys, os
if not hasattr(sys, 'frozen'):
f = os.path.join(os.path.dirname(__file__), 'myole4ax.tlb')
cc.GetModule(f)
from comtypes.gen import myole4ax

The intent is that when the app is running in a non-frozen state (IOW,
without py2exe) then it will load the activex component from the same
location as activex.py and comtypes will make a module for it in
comtypes.gen. When it is running from a frozen app (IOW in a py2ex'd
form) then it will just import from comtypes.gen and skip the rest. So
basically you need to run the application from source before you can
bundle it up with py2exe.

> Is there anything wrong with my setup.py. I tried with bundled files =
> 3 and 1. My goal is to create one exe only. (i.e. bundled file = 1)

You probably won't be able to do that. Things have been reported to
work much better in an unbundled state. You can instead use one of the
free installer builders to bundle your files into the single .exe that
your users can run to install the collection of files.

--
Robin Dunn
Software Craftsmanhttp://wxPython.org- Hide quoted text -

- Show quoted text -

Chris,

Thanks a lot.. it worked. :slight_smile:

I am able to figure out.
Problem regarding comtypes.gen module is because I have installed
python under program files so I think I din't have permissions so that
I can generate these modules. So, the thumb rule is if you have
installed python under program files then you must have required
permissions.

I think my version of setup.py was also problematic.

Now, I am just looking for some samples which can help me to talk to
the ActiveX (In this case.. calling functions Load, setting FlashVars
and other related stuff). I got some samples but those are old ones
(for flashwin_old.py) because there is no EVT_FSCommand in the files.
I think there's not much stuff available for this particular activex.
Any pointers in this direction will be appreciated.

Once again thanks a lot.

···

On Nov 18, 11:16 pm, Chris Spencer <cspen...@cinci.rr.com> wrote:

I would be shocked if my technique, if used correctly, doesn't work. I
have a program that makes extensive use of the ActiveX Flash wrapper,
and that technique ALWAYS works, and I can bundle just fine.

Do you have these files:
myole4ax.idl
myole4ax.tlb

On the path:
<drive:Python install directory>\Lib\site-packages\wx-2.9.1-msw\wx\lib

If you don't, then you haven't run the wxPython Demo and played
asteroids.

If you have, these files will be picked up by py2exe.

I have had the line "bundle_files" commented out for YEARS, but put it
into the "Setup" function of your py2exe script:

setup(
options = {"py2exe": {"compressed": 1,
"optimize": 2,
"ascii": 1,
"bundle_files": 3,
"packages": ["encodings"],
"includes": ["decimal","shlex","os"],
}
},
zipfile = None,
# console = [program],
bundle_files = [
(r"wx/lib",[r"C:\Python27\Lib\site-packages\wx-2.9.1-msw\wx\lib\myole4ax.id­l",r"C:\Python275\Lib\site-packages\wx-2.9.1-msw\wx\lib\myole4ax.tlb"])
]
windows = [program],
)

See if that works.

Chris.

On Thu, 18 Nov 2010 20:45:59 -0800 (PST), Humble Learner > > > > <nava...@gmail.com> wrote:
>I tried what has been recommended by Chris but no luck!!!

>Just want to confirm that is it really work in that way? If not then
>is there any way to pack falshwindow in py2exe? any workaround? I've
>spent so many days on it. :frowning:

>On Nov 18, 8:35 pm, Robin Dunn <ro...@alldunn.com> wrote:
>> On 11/18/10 7:09 PM, Humble Learner wrote:

>> > Hi Freinds,

>> > I try to build a sample using ActiveX app (like Flash window). I have
>> > following components installed on my windows machine:

>> > py2exe + wx.lib.flashwin + Python 2.7 + wxPython 2.8.11 + comtypes

>> > When I execute it using "python.exe testActivex.py" it works fine and
>> > I'm able to open flash file. So, I tried to generate exe using py2exe
>> > but I got the following error:

>> > 18:57:22: Debug: src/helpers.cpp(140): 'CreateActCtx' failed with
>> > error 0x0000007b (the filename, directory name, or volume label syntax
>> > is incorrect.).
>> > Traceback (most recent call last):
>> > File "testflv.py", line 27, in<module>
>> > File "zipextimporter.pyo", line 82, in load_module
>> > File "wx\lib\flashwin.pyo", line 15, in<module>
>> > File "zipextimporter.pyo", line 82, in load_module
>> > File "wx\lib\activex.pyo", line 44, in<module>
>> > ImportError: cannot import name myole4ax

>> > I have been digging about this since last two days. I've tried to read
>> > whatever I can from comtypes.gen to activex to sys.frozen attributes.
>> > I have also read that myole4ax.tlb was missing in some of the wxPython
>> > versions(can't believe). After spending this much time I'm not able to
>> > resolve the issue.

>> Here's the code in question:

>> import sys, os
>> if not hasattr(sys, 'frozen'):
>> f = os.path.join(os.path.dirname(__file__), 'myole4ax.tlb')
>> cc.GetModule(f)
>> from comtypes.gen import myole4ax

>> The intent is that when the app is running in a non-frozen state (IOW,
>> without py2exe) then it will load the activex component from the same
>> location as activex.py and comtypes will make a module for it in
>> comtypes.gen. When it is running from a frozen app (IOW in a py2ex'd
>> form) then it will just import from comtypes.gen and skip the rest. So
>> basically you need to run the application from source before you can
>> bundle it up with py2exe.

>> > Is there anything wrong with my setup.py. I tried with bundled files =
>> > 3 and 1. My goal is to create one exe only. (i.e. bundled file = 1)

>> You probably won't be able to do that. Things have been reported to
>> work much better in an unbundled state. You can instead use one of the
>> free installer builders to bundle your files into the single .exe that
>> your users can run to install the collection of files.

>> --
>> Robin Dunn
>> Software Craftsmanhttp://wxPython.org-Hide quoted text -

>> - Show quoted text -- Hide quoted text -

- Show quoted text -