Deploy Issue: pywin32

I’m having difficulty deploying a machine. It’s getting stuck with pywin32, which is a requirement for my app. I don’t know if has that package disabled or if there’s something else happening. Would love anyone’s feedback on how to get this working.

#0 2.681 ERROR: Could not find a version that satisfies the requirement pywin32 (from versions: none)
#0 2.682 ERROR: No matching distribution found for pywin32
Error: failed to fetch an image or build from source: error building: failed to solve: executor failed running [/bin/sh -c python -m pip install -r requirements.txt]: exit code: 1

Hi @stockwet

Fly Machines run Linux. I don’t think you can install pywin32 on Linux. You may need to modify your requirements.txt file to require pywin32 only on Windows, and modify the code to detect whether the app is running on win32 or Linux at runtime and only use the package on win32.

pywin32 is just an extension library in python. It’s not a windows app being installed. My code checks for the OS type before invoking the library. So, I’m not really sure I understand how the install platform matters. pywin32 · PyPI

This is not pywin32 is uninstallable on non-Windows systems, here’s an attempt on an Ubuntu 22.04 system:

$ trolo/bin/pip install pywin32 
ERROR: Could not find a version that satisfies the requirement pywin32 (from versions: none)
ERROR: No matching distribution found for pywin32
$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 22.04.3 LTS
Release:	22.04
Codename:	jammy

If you try this with verbosity (-v -v) pip will tell you the reason, mainly that all the prebuilt wheels want a windows system tag (example: Skipping link: none of the wheel's tags (cp39-cp39-win_amd64) are compatible (run pip debug --verbose to show compatible tags) - note win_amd64.

Also, checking pywin32’s pypi page, it says “the Python for Win32 (pywin32) extensions, which provides access to many of the Windows APIs from Python.” - it sounds unlikely it would be able to provide access to Windows APIs on Linux.

The source code is available so it’s likely you might be able to build a custom wheel that installs on Linux, or perhaps you can cajole pip into installing it anyway, but you’d have to look into that on your side. For starters, the script seems to mention a lot of Windows-only constructs and the compilation instructions say you need “Visual Studio 2019” anyway.


  • Daniel
1 Like

Thanks @pavel and @roadmr. Appreciate the responses. Sorry for doubting your original reply, @pavel! :slight_smile:

So, not specific follow-up question. My code is extracting out the raw clipboard data. Any ideas how to get this done with either another module or an entirely different language platform that’s more universal than relying on the windows extensions?

def get_clipboard_html_windows():
        result =
            ["powershell", "get-clipboard", "-Raw", "-TextFormatType", "Html"],
        if result.returncode == 0:
            return result.stdout
            print("Failed to get clipboard content.")
            return None
    except Exception as e:
        print("Error:", e)
        return None

This is the clipboard data I’m trying to extract. This isn’t the typical “paste” function which is readily available in packages like pyperclip or clipboard. I have to inspect the full HTML raw clipboard data. I’d like to be able to deploy to fly.

<!--StartFragment--><meta charset="utf-8"><span data-tradingview-clip="{"sources":[{"type":"drawing","geometry":[{"x":0.5748417416493814,"y":0.5668696585616829},{"x":0.843941973328565,"y":0.5866510137377625},{"x":0.5848084168967586,"y":0.5668696585616829}],"source":{"type":"LineToolRiskRewardLong","id":"8ImQrp","state":{"linecolor":"rgba(120, 123, 134, 1)","linewidth":1,"textcolor":"#ffffff","fontsize":12,"fillLabelBackground":true,"labelBackgroundColor":"#585858","fillBackground":true,"stopBackground":"rgba(240, 98, 146, 0.2)","profitBackground":"rgba(0, 151, 167, 0.2)","stopBackgroundTransparency":80,"profitBackgroundTransparency":80,"drawBorder":false,"borderColor":"#667b8b","compact":true,"riskDisplayMode":"money","accountSize":100000,"lotSize":1,"risk":200,"alwaysShowStats":false,"showPriceLabels":true,"symbolStateVersion":2,"zOrderVersion":2,"visible":true,"frozen":false,"symbol":"CME_MINI:NQU2022","currencyId":"USD","unitId":null,"title":"Long","interval":"5","stopLevel":138,"profitLevel":461,"riskSize":200,"qty":0.2898550724637681,"amountTarget":100668.12,"amountStop":99800},"points":[{"time_t":1658339400,"offset":0,"price":12391},{"time_t":1658347500,"offset":0,"price":12380.25},{"time_t":1658339700,"offset":0,"price":12391}],"zorder":-31250,"ownerSource":"_seriesId","linkKey":"lFoFCzGlnuHJ","sharingMode":1,"version":2},"modelId":"8061dbf3-d808-49d8-93cf-b290890308be"}],"title":"Long Position"}">Long Position</span><!--EndFragment-->

In this case I think you can do something like this in requirements.txt:

pywin32==<version>; sys_platform == 'win32'

This should prevent pypi from trying to install pywin32 on a non-Windows platform.

@stockwet The code as you have it now works because you’re running it on the same system: that is, you run the web server on your workstation, then access it on the same workstation with a browser (http://localhost:xxxx, right?). So executing powershell commands works since the server is running on the same system you’re on.

When you move your service into a network server, things change fundamentally: even if you could run powershell on the server, it would obviously not have access to your local system’s (or any other client’s) clipboard that way. It only has local access to things on the server itself, which is clearly not what you want.

Instead, the portion of your code that is running on the user’s machine is the Javascript code that is executed as part of your page loading. So you will have to rearchitect your code to have some Javascript which fetches clipboard contents and sends them to your server for processing.

I can’t provide a lot of specifics since I don’t know what your application does or how it’s designed; there are a series of Javascript clipboard APIs you’d need to look into, like this one, and an example here.


  • Daniel

Thanks a ton. That gets me going in the right direction.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.