473,516 Members | 3,138 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 _pickSomeNonDaemonThread
File "c:\ADP86Tools\bin\sacd.py", line 44, in ?
filterwarnings("ignore", category=FutureWarning)
File "warnings.pyc", line 140, in filterwarnings
File "re.pyc", line 5, in ?
File "sre.pyc", line 97, in ?
File "sre_compile.pyc", 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*********@zoran.com>
http://tebeka.spymac.net
The only difference between children and adults is the price of the toys
Jul 18 '05 #1
2 2323
"Miki Tebeka" <mi*********@zoran.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 _pickSomeNonDaemonThread
File "c:\ADP86Tools\bin\sacd.py", line 44, in ?
filterwarnings("ignore", category=FutureWarning)
File "warnings.pyc", line 140, in filterwarnings
File "re.pyc", line 5, in ?
File "sre.pyc", line 97, in ?
File "sre_compile.pyc", 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_exe.py, the
template is this:
LOADER = """
def __load():
import imp, os, sys
dirname = sys.prefix
path = os.path.join(dirname, '%s')
#print "py2exe extension module", __name__, "->", path
mod = imp.load_dynamic(__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 _pickSomeNonDaemonThread
File "c:\ADP86Tools\bin\sacd.py", line 44, in ?
filterwarnings("ignore", category=FutureWarning)
File "warnings.pyc", line 140, in filterwarnings
File "re.pyc", line 5, in ?
File "sre.pyc", line 97, in ?
File "sre_compile.pyc", 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*********@zoran.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
2494
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)...
13
2774
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...
6
4427
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 =...
3
3759
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...
35
3032
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...
68
5775
by: Lad | last post by:
Is anyone capable of providing Python advantages over PHP if there are any? Cheers, L.
11
4228
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...
20
22471
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...
4
2813
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...
0
7276
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
7182
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...
0
7408
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. ...
1
7142
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
7548
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...
0
5714
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
4773
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
1624
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
825
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.