This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Windows installer created with Python X.Y does not work with Python X.Y+1
Type: behavior Stage:
Components: Distutils, Windows Versions: Python 3.2, Python 2.7
process
Status: closed Resolution: duplicate
Dependencies: Superseder: 2.6.1 breaks many applications that embed Python on Windows
View: 4566
Assigned To: tarek Nosy List: BreamoreBoy, alexis, dstufft, eric.araujo, eryksun, loewis, paul.moore, rantanen, steve.dower, tarek, tim.golden, zach.ware
Priority: normal Keywords:

Created on 2009-01-12 05:28 by rantanen, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
simple.zip rantanen, 2009-01-12 05:28 Simple project
Messages (8)
msg79647 - (view) Author: Juha Rantanen (rantanen) Date: 2009-01-12 05:28
1. Create Windows installer with Python 2.5 from attached project.
2. Install it with Python 2.6.1.
3. The post-installer will fail with error message: 
*** run_installscript: internal error 0xFFFFFFFF ***

The code causing this is:

import socket

and the actual error is:

ImportError
DLL load failed: The specified module could not be found.
  File "<string>", line 6, in windows_binary_install
  File "c:\apps\python26\lib\socket.py", line 46, in <module>
    import _socket

If the installer is created with Python 2.6.1, it works fine. 

The problem was noticed in the Robot Framework project and the issue can
be found from http://code.google.com/p/robotframework/issues/detail?id=196.

This problem was first asked as part of issue
http://bugs.python.org/issue4566, but Martin v. Löwis recommended to
open new issue for this.
msg79648 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2009-01-12 05:46
Was the 2.6 installation "for all users", or "just for me"? What Windows
version are you using?
msg79649 - (view) Author: Juha Rantanen (rantanen) Date: 2009-01-12 07:55
Python 2.6.1 was installed with option all users. I have admin rights
and the Windows version is:
XP Professional
Version 2002
Service Pack 3
msg153678 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2012-02-19 09:03
Not sure if there is much to be done here; I don’t know if it is a reasonable expectation that an installer created with 2.X still work with 2.X+1, and anyway only 2.7 could get a bugfix now.
msg153691 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2012-02-19 10:01
Installers "ought to" work for subsequent versions if they contain pure-Python packages (i.e. no extension modules). I agree that the issue is obsolete for 2.x, but it may still exist for 3.x.
msg153694 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2012-02-19 10:19
Thanks, keeping it open.  If I manage to get a VM set up I will see if this is reproducible.
msg251553 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2015-09-24 22:31
Can this be closed as history with so many changes having been made to the installer for 3.5?
msg251566 - (view) Author: Eryk Sun (eryksun) * (Python triager) Date: 2015-09-25 03:15
There haven't been any fundamental changes to bdist_wininst in years, and bdist_wheel has mostly replaced it nowadays. 

I'm fairly certain this issue was fixed by Mark Hammond's fix for issue 4566. Just to be certain, I updated the code to use print as a function and used 3.4 to build "Simple-Python 3.4.3.win-amd64.exe". I installed this to 3.5, and the post-install script ran successfully. So I'm re-tagging this issue for versions 2.7 and 3.2 and closing it as a duplicate.

In summary, Python built with VS 2008 needs an activation context for the CRT assembly, which is required to load msvcr90.dll. Normally this comes from the application executable, such as python.exe. But when Python is embedded, it may be the case that the application lacks the required activation context (e.g. a bdist_wininst installer created by Python 2.5). Mark Hammond's fix works around this problem by saving and reusing the activation context from when the Python DLL was loaded. This activation context is based on the DLL's resource #2 manifest, which includes the CRT assembly.

One remaining problem for embedding Python 2.7 is accessing msvcr90.dll via ctypes. But it's ctypes! Just dynamically create an activation context.
History
Date User Action Args
2022-04-11 14:56:44adminsetgithub: 49168
2015-09-25 03:15:07eryksunsetstatus: open -> closed

superseder: 2.6.1 breaks many applications that embed Python on Windows
versions: + Python 2.7, Python 3.2, - Python 3.5, Python 3.6
nosy: + eryksun

messages: + msg251566
resolution: duplicate
2015-09-24 22:31:38BreamoreBoysetnosy: + paul.moore, tim.golden, BreamoreBoy, zach.ware, steve.dower

messages: + msg251553
versions: + Python 3.6, - Python 2.7, Python 3.4
2014-06-15 17:15:57BreamoreBoysetnosy: + dstufft

components: - Distutils2
versions: + Python 3.4, Python 3.5, - 3rd party, Python 3.2, Python 3.3
2012-02-19 10:19:05eric.araujosettitle: Windows installer created with Python 2.5 does not work with Python 2.6.1 -> Windows installer created with Python X.Y does not work with Python X.Y+1
nosy: + alexis

messages: + msg153694

versions: + 3rd party, Python 2.7, Python 3.2, Python 3.3
components: + Distutils2
2012-02-19 10:01:34loewissetmessages: + msg153691
2012-02-19 09:03:51eric.araujosetnosy: + eric.araujo
title: Windows installer created with Python 2.5 does not work with Python 2.6.1 -> Windows installer created with Python 2.5 does not work with Python 2.6.1
messages: + msg153678

versions: - Python 2.6
2010-02-09 16:47:09brian.curtinsetpriority: normal
type: crash -> behavior
2009-03-01 23:41:59akitadasetnosy: + tarek
type: crash
components: + Windows
assignee: tarek
2009-01-12 07:55:52rantanensetmessages: + msg79649
2009-01-12 05:46:09loewissetnosy: + loewis
messages: + msg79648
2009-01-12 05:28:22rantanencreate