Forums

Can I load win32com.client module on python anywhere if it only works on windows?

I am looking to convert an xlsx file to xls. The only way I have found to do this with python involve win32com.client. I am under the impression this only works on windows machines. Would this work on python anywhere.

Below is a stackoverflow question that explains how this conversion would be done with win32com.client.

http://stackoverflow.com/questions/12960556/converting-xlsx-to-xls-in-python-with-win32com-client-module

The win32com.client module definitely won't work on PythonAnywhere.

Perhaps you could do something with using openpyxl to read the file and xlwt to write it?

can openpyxl take note of the background color of cells? That's pretty much the only reason I need to convert it. I need to avoid capturing data that is highlighted in yellow. (Terrible system, I know. Sometimes no matter how hard you try, you can't teach people to try new things once they get used to a system).

It looks like you can get the style of a cell so the colors should be in there.

Thank you!

I need win32com.client to convert doc to docx. I upload win32com folder manually under folder 'site-packages' and made the error message change from "No module named 'win32com'" to "No module named 'win32api'". But 'win32api.pyd' is actually under '.../site-packages/win32'.

Could anyone know how to solve this problem? Either ideas about other ways to read in doc files by python and convert to docx OR made win32com.client work on pythonanywhere will be very welcome. Thanks in advance!

The log message is copied below: 2019-02-01 07:17:17,548: Error running WSGI application 2019-02-01 07:17:17,548: ModuleNotFoundError: No module named 'win32api' 2019-02-01 07:17:17,548: File "/var/www/lexi_pythonanywhere_com_wsgi.py", line 16, in <module> 2019-02-01 07:17:17,548: from detector import app # noqa 2019-02-01 07:17:17,549: 2019-02-01 07:17:17,549: File "/home/lexi/mysite/detector.py", line 16, in <module> 2019-02-01 07:17:17,549: import win32com.client 2019-02-01 07:17:17,549: 2019-02-01 07:17:17,549: File "/home/lexi/.virtualenvs/dashappenv/lib/python3.6/site-packages/win32com/init.py", line 5, in <module> 2019-02-01 07:17:17,549: import win32api, sys, os

As giles said before win32com is only for Windows and PythonAnywhere does not run Windows, so you cannot install it.

This StackOverflow question looks like it has a few alternative options.

Actually I need read in DOC files, the StackOverflow question seems for DOCX files. Thanks for the reply.

Ok. I'm not too clear on the difference, but I'd guess that you should be able to find a Python library that will do it after a bit of googling around.

The win32com.client module cannot work on PythonAnywhere. you can use alternative methods use openpyxl to read the file and xlwt to write in the file

This is a dealbreaker for me, if win32com.client does not work on pythonanywhere, then I can't use pythonanywhere, unfortunately.

It will not work on PythonAnywhere.