Install win32com on MacOs and Linux [duplicate]
Asked Answered
T

1

6

My question is simple: can I install win32com python API (pywin32 notably) on an OS that is not Windows?

I have been trying, on Mac, multiple versions of pip install pywin32, all have failed. An example below:

enter image description here

If you managed to install it on Linux I am also interested as I wrote it.

I am using python 3.7.8.

Thanks.

Tommy answered 23/11, 2020 at 20:28 Comment(8)
win32com provides Python bindings for Win32 API. There are no Win32 APIs on non-Win32 OSes.Legrand
Ok, thanks for the semantic correction. What about the fact to install the python library on mac and Linux?Tommy
Maybe you could install it with a bit of persuasion. What would it do then?Legrand
Can you help me out with it, please? The first plan would be to use outlook to send automatic emailsTommy
No sorry, I totally can't help you out with this.Legrand
It's not semantics. Bindings to an OS-specific library won't do anything outside the OS that library provides integration with. Technically it might be possible to install win32com on Python for Windows installed on MacOS or Linux with WINE, but it's very unlikely that doing so will actually help you accomplish whatever-it-is that you mean to be doing. If you asked us about that whatever-it-is that's your actual end goal, we might be able to provide better answers than when you ask us about something impossible you think is a necessary step towards that goal.Crepitate
Thank you @CharlesDuffy I thought doing well with splitting my global issue into chunks and sharing the blocker with you. If we had to share the whole context each time we had a blocker, we'd spend our lives doing so. My "whatever actual end goal" is like everyone else's I guess : go through the life given to me as happy and peaceful as possibleTommy
Right; the thing is that if working around the blocker adds new complications (as it would), it's worth considering whether other chunks can be arranged with less pain than addressing those complications (in this case, for example, getting Outlook's COM component to work under WINE would be among those complications; replacing any Linux-native / non-WINE-compatible Python libraries, likewise). Asking only about a single perceived blocker prevents more holistic answers, like ways to send Exchange email from Linux without involving Outlook or COM.Crepitate
S
5

Win32COM is part of [GitHub]: mhammond/pywin32 - pywin32.
According to the (above) URL, the package is only designed to work on Win:

Python for Win32 (pywin32) extensions

So, this is Win specific (it was never intended for other OSes).

As for your question, technically you could install it on Linux, or OSX (it is possible with some manual steps), but that would make absolutely no difference, because (even if installed) it would NOT run on those platforms, as it contains (consists of) binaries (.dlls) that don't run (can't be loaded by processes) on non Win OSes.

Just looked at the comments: [MS.Docs]: Office.MessageCompose interface is available on OSX, but (most likely, if there isn't already a Python wrapper available) you'd have to write the bindings yourself (their examples are in JS).



Additional (generic) information

Some packages are only meant to work in specific conditions, based on restricting criteria like:

  • Platform(s) (OS, CPU architecture)

  • Python version(s)

  • ...

even if not enforced by the installation mechanism (meaning they can somehow end up "installed" on platforms that they don't work on).
Anyway, such restrictions are (should be) mentioned (example for PyWin32 - see the red boxes) in package's:

  • PyPI page

    Img0

  • Homepage

    Img1

  • Other resources (e.g.: package's doc page, if it has one)

Bottom line is that such a package will not work outside the conditions it was meant to run in (even if it can be installed), and more: when attempting to run it, will yield some error message that might not be very clear.

There are packages with such restrictions, but can be installed outside them:

  • Win:

    • ComTypes

      • Error:

        [cfati@cfati-5510-0:/mnt/e/Work/Dev/StackOverflow/q064975918]> python -c "import comtypes"
        Traceback (most recent call last):
          File "<string>", line 1, in <module>
          File "/home/cfati/.local/lib/python3.8/site-packages/comtypes/__init__.py", line 28, in <module>
            from _ctypes import COMError
        ImportError: cannot import name 'COMError' from '_ctypes' (/usr/lib/python3.8/lib-dynload/_ctypes.cpython-38-x86_64-linux-gnu.so)
        
      • Fix (improvement): [GitHub]: enthought/comtypes - Improve error message on non Win

    • WConio2

      • Error:

        [cfati@cfati-5510-0:/mnt/e/Work/Dev/StackOverflow/q064975918]> python -c "import WConio2"
        Traceback (most recent call last):
          File "<string>", line 1, in <module>
          File "/home/cfati/.local/lib/python3.8/site-packages/WConio2.py", line 125, in <module>
            from ctypes import windll
        ImportError: cannot import name 'windll' from 'ctypes' (/usr/lib/python3.8/ctypes/__init__.py)
        
      • Fix (improvement): [GitHub]: Solomoriah/WConio2 - Improve error message on non Win

Related (more or less):

Syntactics answered 27/11, 2020 at 0:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.