Pywin32 icon indicating copy to clipboard operation
Pywin32 copied to clipboard

win32api cannot be imported on Sublime Text 4: 3.3 binaries load in the modern host (no .python-version)

Open dpc00 opened this issue 1 month ago • 4 comments

Claude reports:

On Sublime Text 4215 (Windows 11, plugin host Python 3.14.6), Pywin32 1.1.0 installs and its setup adds the paths, but the extension modules cannot be imported.

Pywin32: Added 'win32'
Pywin32: Added 'win32/lib'
Pywin32: Added 'win32com'
Pywin32: Added 'win32comext'

sys.path: ...\Data\Packages\Pywin32\lib\x64\win32, ...\lib\x64\win32\lib, ...\lib\x64, ...\lib\x64\win32comext

>>> import win32api
ImportError: Module use of python33.dll conflicts with this version of Python.
>>> import win32con
(works - pure Python)

Packages/Pywin32/lib/x64/win32 contains pythoncom33.dll, _win32sysloader.pyd, pythonservice.exe - builds for Python 3.3. package-metadata.json says "python_version": "3.3", but the package ships no .python-version file, so Sublime Text 4 loads it in the modern host (3.14 here), where the 3.3 .pyd files refuse to load.

Fix: ship a .python-version containing 3.3 so ST4 loads the package in the legacy host that matches these binaries, or move to current CPython builds. With the former, import win32api should work again the way it does on Sublime Text 3.

dpc00 avatar Nov 05 '26 02:11 dpc00

Fix: ship a .python-version containing 3.3

Does that work when 3.3 is explicitly disabled in the ST settings? And if it's not disabled, ST will use 3.3 even without that file.

michaelblyons avatar Nov 05 '26 02:11 michaelblyons

Measured on 4215 (Windows 11), answering the two points:

Shipping .python-version with 3.3 does not work when 3.3 is disabled — and disabled is the default. The 4215 changelog says: "Python 3.3 is disabled by default and will be removed in a future version. If you're experiencing plugin compatibility issues you can re-enable 3.3 using the setting disable_plugin_host_3.3: false." With the default no plugin_host-3.3.exe runs, and a probe package whose .python-version contains 3.3 prints PyProbe host: 3.14.6. The same file added to Pywin32 changed nothing: its setup still added its paths to the 3.14 sys.path and import win32api still failed with the python33.dll error.

You are right about the enabled case. With "disable_plugin_host_3.3": false, the same probe package runs as PyProbe host: 3.3.7, and Pywin32 needs no .python-version at all — the console shows reloading python 3.3 plugin Pywin32.setup followed by Pywin32: Added 'win32' ..., so an unversioned package lands in 3.3 once the host is on.

So my suggested fix only helps people who have turned the old host back on, and does nothing for a default install. The real choice seems to be: document that this package needs disable_plugin_host_3.3: false (with the note that 3.3 will be removed), or ship extension modules built for the host ST now uses, possibly through Package Control libraries. Which way would you rather it went? I can retest either.

dpc00 avatar Nov 05 '26 03:11 dpc00

This repository represents a legacy dependency of pywin32 for compatibility with ST3 and python 3.3, only.

As of python 3.8, Package Control pulls official package from pypi.

deathaxe avatar Nov 05 '26 11:11 deathaxe

For the reasons mentioned here and in the README, this package is deprecated and should not be used. Thus, we also won't be fixing any bugs with it.

I would rather create a new release with an update message about this fact and archive it instead.

FichteFoll avatar Nov 07 '26 01:11 FichteFoll