473,657 Members | 2,428 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Embedded Python application don't work if Python is installed

Hello All,

I have a funny problem:

An embedded python application is working fine on a "clean" computer.
When it runs on a computer with python installed (the very same computer
used to produce the application) it has a import error:
----------
can't import SACD module (sacd.py)
Error in sys.exitfunc:
Traceback (most recent call last):
File "atexit.pyc ", line 20, in _run_exitfuncs
File "threading.pyc" , line 566, in __exitfunc
File "threading.pyc" , line 578, in _pickSomeNonDae monThread
File "c:\ADP86Tools\ bin\sacd.py", line 44, in ?
filterwarnings( "ignore", category=Future Warning)
File "warnings.p yc", line 140, in filterwarnings
File "re.pyc", line 5, in ?
File "sre.pyc", line 97, in ?
File "sre_compile.py c", line 13, in ?
File "_sre.pyc", line 9, in ?
File "_sre.pyc", line 7, in __load
ImportError: DLL load failed: The specified module could not be found.
----------
(The traceback is printed from the embedding application)

All the required modules are in a library (python23.zip) and placed
the needed dll's in the same directory as the application (it's in
sys.path).
The script itself is a regular python file (.py), dependencies were found
using py2exe.

OS is win2k and Python is 2.3.4.

I've tried editing sys.path to contain only the application directory and
the library zip and also to add the application directory to PATH
environment variables. Nothing helps.

The offending module is re. Writing
import re
re.compile("\s+ ")
will cause the same problem.

Any ideas?

Bye.
--
------------------------------------------------------------------------
Miki Tebeka <mi*********@zo ran.com>
http://tebeka.spymac.net
The only difference between children and adults is the price of the toys
Jul 18 '05 #1
2 2333
"Miki Tebeka" <mi*********@zo ran.com> writes:
Hello All,

I have a funny problem:

An embedded python application is working fine on a "clean" computer.
When it runs on a computer with python installed (the very same computer
used to produce the application) it has a import error:
----------
can't import SACD module (sacd.py)
Error in sys.exitfunc:
Traceback (most recent call last):
File "atexit.pyc ", line 20, in _run_exitfuncs
File "threading.pyc" , line 566, in __exitfunc
File "threading.pyc" , line 578, in _pickSomeNonDae monThread
File "c:\ADP86Tools\ bin\sacd.py", line 44, in ?
filterwarnings( "ignore", category=Future Warning)
File "warnings.p yc", line 140, in filterwarnings
File "re.pyc", line 5, in ?
File "sre.pyc", line 97, in ?
File "sre_compile.py c", line 13, in ?
File "_sre.pyc", line 9, in ?
File "_sre.pyc", line 7, in __load
ImportError: DLL load failed: The specified module could not be found.
----------
(The traceback is printed from the embedding application)


No solution, but hopefully some hints how to approach this.

First, but maybe you have seen this already, isn't the real problem that
SACD cannot be imported? Where is the traceback for that?
The traceback above imo only shows that there's a problem shutting down
the application. The top frame refers to atexit running the exitfuncs.
The last frame shows that py2exe imports extension modules (_sre.pyd in
this case, required by warnings as it seems) in a different way: via a
small python loader, named _sre.py(c), in the library.zip file.
You can look up the loaders sourcecode in py2exe\build_ex e.py, the
template is this:
LOADER = """
def __load():
import imp, os, sys
dirname = sys.prefix
path = os.path.join(di rname, '%s')
#print "py2exe extension module", __name__, "->", path
mod = imp.load_dynami c(__name__, path)
## mod.frozen = 1
__load()
del __load
"""
This is because the *only* item on sys.path is the library.zip file.
So, it seems that your exitfunc tries to print a warning, and cannot,
because it cannot import _sre.pyd any more (maybe because Python has
shut down partly?).

Second, you say the problem only shows up on a computer where python is
installed. To track down this, you can define a PY2EXE_VERBOSE
environment variable before running the exe - this has the same effect
as the PYTHONVERBOSE env var, or the -v flag, for normal Python: it
traces import statements to the console.

Hopefully this helps you to find out the different behaviour in both
cases.

Thomas
Jul 18 '05 #2
Hello Thomas,
An embedded python application is working fine on a "clean" computer.
When it runs on a computer with python installed (the very same computer
used to produce the application) it has a import error:
----------
can't import SACD module (sacd.py)
Error in sys.exitfunc:
Traceback (most recent call last):
File "atexit.pyc ", line 20, in _run_exitfuncs
File "threading.pyc" , line 566, in __exitfunc
File "threading.pyc" , line 578, in _pickSomeNonDae monThread
File "c:\ADP86Tools\ bin\sacd.py", line 44, in ?
filterwarnings( "ignore", category=Future Warning)
File "warnings.p yc", line 140, in filterwarnings
File "re.pyc", line 5, in ?
File "sre.pyc", line 97, in ?
File "sre_compile.py c", line 13, in ?
File "_sre.pyc", line 9, in ?
File "_sre.pyc", line 7, in __load
ImportError: DLL load failed: The specified module could not be found.
----------
(The traceback is printed from the embedding application)
First, but maybe you have seen this already, isn't the real problem that
SACD cannot be imported? Where is the traceback for that?

The SACD module can be imported on a machine without Python installed and
it's working.
The traceback above imo only shows that there's a problem shutting down
the application. The application is shutting down since SACD can't be imported.
This is because the *only* item on sys.path is the library.zip file. Nope, printing sys.path showed that all the "regular" Python path is in.
Second, you say the problem only shows up on a computer where python is
installed. To track down this, you can define a PY2EXE_VERBOSE
environment variable before running the exe - this has the same effect
as the PYTHONVERBOSE env var, or the -v flag, for normal Python: it
traces import statements to the console.

This is *not* a python script wrapped with py2exe. py2exe was
used only to find the dependencies and create the zip file (which was
renamed to python23.zip).

I've found out that if I remove the _sre.pyd and the zip library everything
works on a computer with Python installed. However I'm still in the dark on
how to solve this.

Thanks for your time.

Bye.
--
------------------------------------------------------------------------
Miki Tebeka <mi*********@zo ran.com>
http://tebeka.spymac.net
The only difference between children and adults is the price of the toys
Jul 18 '05 #3

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

Similar topics

10
2508
by: John Underwood | last post by:
Can I use python23_d and python23 to develop an extension for a commercial application uses python22.dll? (Providing that I do not use any new features found only in 2.3.) I would bulld version 2.2 but I am having trouble doing this with Visual Studio .NET Standard. (There is a well documented problem with version 2.2 (involving largeint.h) and VS.NET but none of the solutions that I found have worked.) On the other hand, I have...
13
2797
by: Alexander May | last post by:
Hi, I love Python! I've been using it for a couple of years now and have found it to be a highly productive language. I evangelize it to my developer friends and am probably responsible for the sale of at least 10 Alex Martelli books. I am now in the fortunate position of being able to use Python for a large project, and as such I have a question. We are developing a distributed application running on approximately six thousand...
6
4434
by: Farshid Lashkari | last post by:
Hi, My application has python embedded into it. I noticed that when I run any python code the output is buffered and doesn't get flushed until my application exits. To fix this I simply flush sys.stdout and sys.stderr every once in while by using the following code: //Get handle to python stdout file and flush it PyObject *pyStdout = PySys_GetObject("stdout"); if(pyStdout && PyFile_Check(pyStdout)) {
3
3770
by: Matthias Baas | last post by:
Hi, are there any guidelines about what to do if a Windows extension for Python 2.4 requires the C++ runtime (msvcp71.dll)? If I want to distribute a binary installer of an extension that contains C++ code, should I really include the msvcp71.dll in the package? It doesn't sound like a good idea to me if every package places another copy of this dll somewhere in the Python directory. Python 2.4 does install the C runtime (msvcr71.dll)...
35
3070
by: Michael Kearns | last post by:
I've been using python to write a simple 'launcher' for one of our Java applications for quite a while now. I recently updated it to use python 2.4, and all seemed well. Today, one of my colleagues noted that on her machine the launcher would complain it was missing a DLL - msvcr71.dll However, there's a very grey area concerning the redistribution of said DLL. If you've been keeping up with the dev list, and some other web
68
5840
by: Lad | last post by:
Is anyone capable of providing Python advantages over PHP if there are any? Cheers, L.
11
4253
by: Mark Yudkin | last post by:
The documentation is unclear (at least to me) on the permissibility of accessing DB2 (8.1.5) concurrently on and from Windows 2000 / XP / 2003, with separate transactions scope, from separate threads of a multithreaded program using embedded SQL. Since the threads do not need to share transaction scopes, the sqleAttachToCtx family of APIs do not seem to be necessary. <quote> In the default implementation of threaded applications against...
20
22502
by: Jack | last post by:
Is there a Python packaging that is specifically for embedded systems? ie, very small and configurable so the user gets to select what modules to install? For Linux-based embedded systems in particular? I'm thinking of running it on the Linksys's Linux-based open source router WRT54G. It has 4MB flash and 16MB RAM. I think another model has 16MB flash. Any possibilities of running Python on these systems?
4
2824
by: Chris8Boyd | last post by:
I am embedding Python in a MSVC++ (2005) application. The application creates some environment and then launches a Python script that will call some functions exported from the MSVC++ application. I want to be able to debug the Python script by using a debug server, like Winpdb (winpdb.org). I use ActivePython 2.5.2.2, Microsoft Visual Studio 2005, and Winpdb 1.3.8.
0
8420
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8324
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8842
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8617
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7353
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4173
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1970
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1733
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.