1

I've recently had to wipe my laptop and in setting things back up I'm running into an issue where I can't install a certain package I used to use very frequently. Specifically pywin32.

Looking at the debug output, all the compatible tags say either manylinux or linux_x86_64. See snippet below from verbose debug:

  cp310-cp310-manylinux_2_35_x86_64
  cp310-cp310-manylinux_2_34_x86_64
  cp310-cp310-manylinux_2_33_x86_64
  cp310-cp310-manylinux_2_32_x86_64
  cp310-cp310-manylinux_2_31_x86_64
  cp310-cp310-manylinux_2_30_x86_64
  cp310-cp310-manylinux_2_29_x86_64
  cp310-cp310-manylinux_2_28_x86_64
  cp310-cp310-manylinux_2_27_x86_64
  cp310-cp310-manylinux_2_26_x86_64
  cp310-cp310-manylinux_2_25_x86_64
  cp310-cp310-manylinux_2_24_x86_64
  cp310-cp310-manylinux_2_23_x86_64
  cp310-cp310-manylinux_2_22_x86_64
  cp310-cp310-manylinux_2_21_x86_64
  cp310-cp310-manylinux_2_20_x86_64
  cp310-cp310-manylinux_2_19_x86_64
  cp310-cp310-manylinux_2_18_x86_64
  cp310-cp310-manylinux_2_17_x86_64
  cp310-cp310-manylinux2014_x86_64
  cp310-cp310-manylinux_2_16_x86_64
  cp310-cp310-manylinux_2_15_x86_64
  cp310-cp310-manylinux_2_14_x86_64
  cp310-cp310-manylinux_2_13_x86_64
  cp310-cp310-manylinux_2_12_x86_64
  cp310-cp310-manylinux2010_x86_64
  cp310-cp310-manylinux_2_11_x86_64
  cp310-cp310-manylinux_2_10_x86_64
  cp310-cp310-manylinux_2_9_x86_64
  cp310-cp310-manylinux_2_8_x86_64
  cp310-cp310-manylinux_2_7_x86_64
  cp310-cp310-manylinux_2_6_x86_64
  cp310-cp310-manylinux_2_5_x86_64
  cp310-cp310-manylinux1_x86_64
  cp310-cp310-linux_x86_64

Pywin32 on Pypi shows differently (win_arm64, win_amd64, etc): https://pypi.org/project/pywin32/#files

Am I missing something in my fresh WSL? Ive updated everything, installed pip, updated pip, etc.

Note:

    user@ai03:~$ uname -a Linux ai03 5.10.16.3-microsoft-standard-WSL2
    #1 SMP Fri Apr 2 22:23:49 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux 
user@ai03:~$ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description:    Ubuntu 22.04.1 LTS Release:    
    22.04 Codename:       jammy
user@ai03:~$
sinoroc
  • 18,409
  • 2
  • 39
  • 70
addohm
  • 2,248
  • 3
  • 14
  • 40
  • WSL is not Windows. I assume that `pywin32` is meant to be installed on a Windows environment. When you use WSL, you effectively use a Linux environment (at least from the point of view of Python, and obviously it is a bit more complex but it does not matter for your use case). So I would say that it is impossible to install `pywin32` in WSL. – sinoroc Aug 29 '22 at 21:47
  • Its so weird, if thats the case, because I previously set things up this way, as far as I can remember. I wonder if I just set everything up in windows and didn't bother with WSL - it would make sense for me to have done that. – addohm Aug 29 '22 at 21:49
  • That is quite unlikely that it was the case. You should probably install a Python in Windows directly (I would recommend not using the one from the Windows Store because it has issues, pick one from `python.org`). – sinoroc Aug 29 '22 at 21:50
  • 1
    Yeah you we're right in the beginning. I guess my old brain just forgot how I had set things up. – addohm Aug 29 '22 at 21:59
  • 1
    Duplicate: https://stackoverflow.com/q/64975918/4788546 – CristiFati Aug 30 '22 at 04:38
  • 1
    Does this answer your question? [Install win32com on MacOs and Linux](https://stackoverflow.com/questions/64975918/install-win32com-on-macos-and-linux) – FlyingTeller Aug 30 '22 at 08:55
  • @CristiFati why not flag it accordingly? – FlyingTeller Aug 30 '22 at 08:56
  • @FlyingTeller: I want to encourage the authors to do it (and if some things aren't clear for them, give the chance to be clarified in comments). Also the other question doesn't have an accepted answer. – CristiFati Aug 30 '22 at 09:00
  • @sinoroc what's odd/messed up is that why doesn't `pip` recognize that pywin32 is Win only and skip it when running on wsl/linux. It should do that automatically when moving requirements.txt between platforms. – JoelAZ Jun 11 '23 at 09:52
  • @JoelAZ What do you mean? Did you try it? Have you seen _pip_ try to install _pwin32_ on a non-Windows platform? As far as I know this does not happen. Unless there is another issue somewhere, _pip_ tries to look for a distribution package of _pywin32_ compatible with Linux (or Mac or whatever that is not Windows), can not find one, then exits without installing anything as expected. – sinoroc Jun 11 '23 at 10:19
  • @sinoroc absolutely did, that's what prompted my comment. Took a `pip freeze` file from my Win 10 machine to Ubuntu WSL and pip tried to install pywin32, threw an error and choked. That's how I got here in the first place. Solved by commenting out the pywin32 line but I don't think my venv creation should fail for that reason. – JoelAZ Jun 12 '23 at 03:43
  • @JoelAZ OK. Then, yes, it absolutely should fail. At least from my point of view. As far as I know, _pip_ fails gracefully with a correct error message, so it's all good for me. What else should _pip_ do? If _pip_ were to (silently) skip over dependencies when it can not find a matching distribution package, that would lead to unpleasant surprises. – sinoroc Jun 12 '23 at 17:27
  • @sinoroc to be clear, my comment was mostly frustrated venting, not even at you or anyone even in particular. But my thinking is that pyWIN32 is very clearly a platform dependent package (and I'm sure there's a list or smth somewhere that could be checked), and it's reasonable for it to skip that dependency. Or at least stop and ask the user to advise. Crashing out, while technically "correct" in it's error, makes the `pip freeze` output non-portable. And if nothing else I thought the idea of the requirements.txt file was to make my venv portable so I could take it with me. – JoelAZ Jun 13 '23 at 21:39
  • @JoelAZ The output of `pip freeze` is probably not portable indeed, but you can for sure write a portable `requirements.txt` file, either by hand or with the help of some tools. At least I am quite sure it is feasible in the case of `pywin32`, I guess a line like this: `pywin32 ; platform_system == 'Windows'`. – sinoroc Jun 14 '23 at 19:33
  • @sinoroc isn't it? It could be my misunderstanding but I thought that `pip freeze` being the mechanism for "transporting" a venv from A to B would consider the platform specifics. Esp. as Python is supposed to be easily cross-platform. My mistake I guess. Anyway as said, I was just drive-by venting a bit. I can edit the file by hand for sure, just generally disagree that I should have to. – JoelAZ Jun 15 '23 at 21:04
  • @JoelAZ What you are looking for is a "portable lock file". There is no standard for such a thing. A well crafted `requirements.txt` can get you close enough. `pip freeze` does generate lock files in a sense, but not portable. The output of `pip freeze` is only guaranteed to be usable for the same Python implementation, Python version, OS, CPU bitness. As far as I know Poetry claims to have portable lock file. Other tools such as PDM, Hatch also have lock files (if I remember correctly, I might be wrong), not sure if they are portable. Pipenv and pip-tools might be interesting for you as well. – sinoroc Jun 15 '23 at 23:17
  • @sinoroc Thanks for the heads up on those. TIL that lock files are not actually portable. Appreciate heads up on those tools, I'll have a dig into them when I get a chance. Thx. – JoelAZ Jun 16 '23 at 05:27

0 Answers0