473,563 Members | 2,805 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

the problem about the DLL file generate by py2exe

Dear All,

I have try to use the py2exe to compile the DLL file

first i write the simple python script "test01.py" :
def test001():
return 1

then write the setup.py:
# setup.py
from distutils.core import setup
import py2exe
import sys

if len(sys.argv) == 1:
sys.argv.append ("py2exe")
sys.argv.append ("-q")

class Target:
def __init__(self, **kw):
self.__dict__.u pdate(kw)
# for the version info resources (Properties -- Version)
self.version = "0.0.1"
self.company_na me = "Nil"
self.copyright = "Nil"
self.name = "test"

testTK = Target(
# used for the versioninfo resource
description = "test app",
# what to build
modules = ["test01"],
script = "test01.py" ,
# specify which type of com server you want (exe and/or dll)
create_exe = False,
create_dll = True)

#setup(windows=["hkcity_ide_mai n.py"])
setup(
name='Test',
options={"py2ex e": {"bundle_files" : 1, }},
zipfile=None,
version='1.0',
description='Te st',
author='',
author_email='' ,
url='',
ctypes_com_serv er=[testTK],
)
and compile the it by the command:

C:\Python25\pyt hon setup.py py2exe
I use the script try to call the function "test001" in the "test01.py"
from ctypes import *
test01 = cdll.LoadLibrar y("test01.dll ")
test001 = test01.test001
print test01()

However, this is out the error:
AttributeError: function 'test001' not found

Is it any problem when i define the function?

Jun 27 '08 #1
1 2287
em*****@hotmail .com wrote:
Dear All,

I have try to use the py2exe to compile the DLL file

first i write the simple python script "test01.py" :
def test001():
return 1

then write the setup.py:
# setup.py
from distutils.core import setup
import py2exe
import sys

if len(sys.argv) == 1:
sys.argv.append ("py2exe")
sys.argv.append ("-q")

class Target:
def __init__(self, **kw):
self.__dict__.u pdate(kw)
# for the version info resources (Properties -- Version)
self.version = "0.0.1"
self.company_na me = "Nil"
self.copyright = "Nil"
self.name = "test"

testTK = Target(
# used for the versioninfo resource
description = "test app",
# what to build
modules = ["test01"],
script = "test01.py" ,
# specify which type of com server you want (exe and/or dll)
create_exe = False,
create_dll = True)

#setup(windows=["hkcity_ide_mai n.py"])
setup(
name='Test',
options={"py2ex e": {"bundle_files" : 1, }},
zipfile=None,
version='1.0',
description='Te st',
author='',
author_email='' ,
url='',
ctypes_com_serv er=[testTK],
)
and compile the it by the command:

C:\Python25\pyt hon setup.py py2exe
I use the script try to call the function "test001" in the "test01.py"
from ctypes import *
test01 = cdll.LoadLibrar y("test01.dll ")
test001 = test01.test001
print test01()

However, this is out the error:
AttributeError: function 'test001' not found

Is it any problem when i define the function?
I guess you should define a python-function, inside which you call your
dll-function.

Diez
Jun 27 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
3936
by: Luc Saffre | last post by:
Hello, I had a strange problem when freezing (using either py2exe or McMillan installer) a script that imports reportlab (which imports PIL (which imports FixTk))). - Python 2.3.3c (also with Python 2.3) - PIL 1.1.4 - Installer or py2exe : latest versions.
4
1975
by: Werner Merkl | last post by:
Hi, my problem is, I try to use a py2exe compiled python script from a CD-ROM. This should work, BUT the tool I use (or have to use) generates only upper case file names on the CD-ROM. For py2exe 0.4.1 and python 2.2 this worked fine... but the current releases do not.
6
1761
by: Krzysztof Ksi±¿ek | last post by:
Hi! As almost totally newbe, I have written a simple script and I'm proud of it ;-) It connects to ftp server and uploads some files. Kind of backup. I've compiled it with py2exe and put it in autostart. When something is wrong (in example, I'm not connected to the net), it opens a window with some information about error and exact location...
0
1264
by: Oh Kyu Yoon | last post by:
Hi! I am making a small program using boa constructor. This program converts fine into an exe file using py2exe. Then, I embedded a figure canvas from matplotlib in a wxpython panel. I followed the instructions given by py2exe wiki about matplotlib and tried to convert to an exe file. It first said several modules were missing. I realized...
0
1028
by: Daniel Crespo | last post by:
Hi to all, I have an exe file generated by py2exe. It runs perfect, but in some parts of my code I raise exceptions. When I close my exe file, and if it had errors, then they writes down to a .txt file in the same directory of the referred exe file. I would like to not to generate this error. Is it a py2exe option in the setup file? ...
3
1863
by: python | last post by:
I installed it, but can't find py2exe.exe in my computer. why? And , when I execute "python setup.py py2exe" under command line, it prompt error:wrong command "py2exe" .
1
1258
by: Daniel Mark | last post by:
Hello all: I follow the following tutorial http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/108598 Description: script for making executables with py2exe ############## from distutils.core import setup import sys, os, py2exe
1
7633
by: DierkErdmann | last post by:
Hi ! I am trying to create an exe file using pyinstaller. Running the created exe-File gives the error message "" Traceback (most recent call last): File "<string>", line 8, in <module> File "E:\Documents\mich\job\abs\backup_skript\buildbackup\out1.pyz/ email", lin e 79, in __getattr__
2
2204
by: ward.david | last post by:
I am using py2exe to generate an executable so that I can deliver my scripts as a EXE. I have a couple of file that are needed by the program that I do not want to include in the EXE because they are used for program configuration (similar to the way an INI file is used.) These file may change per installation, so I may need to edit them....
0
7665
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7888
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7642
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6255
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3643
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2082
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1200
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
924
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.