Devon
Devon3w ago

Importing docx

question im using windmill web IDE and im importing Document from docx like so: from docx import Document but i get an error: ExecutionErr: ExitCode: 1, last log lines: ine 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "/tmp/windmill/wk-default-7c4b588bcc40-N8AmH/01957f5e-1bdb-5979-73ce-9870d33c4812/wrapper.py", line 10, in <module> from f.Devon.lcm import step_2 as inner_script File "/tmp/windmill/wk-default-7c4b588bcc40-N8AmH/01957f5e-1bdb-5979-73ce-9870d33c4812/f/Devon/lcm/step_2.py", line 3, in <module> from docx import Document File "/tmp/windmill/cache/python_311/docx==0.2.4/docx.py", line 30, in <module> from exceptions import PendingDeprecationWarning ModuleNotFoundError: No module named 'exceptions' problem is the docx is outdated but the guide tells me that windmill uses the newest version any fix for this or what i can do to work around this?
11 Replies
rubenf
rubenf3w ago
Dependencies in Python | Windmill
In Windmill standard mode, dependencies in Python are handled directly within their scripts without the need to manage separate dependency files.
Pyra
Pyra3w ago
Yes, just pin to https://pypi.org/project/python-docx/
# requirements:
# python-docx
# requirements:
# python-docx
Devon
DevonOP3w ago
requirements: docx>=0.8.11 import wmill from docx import Document like this?
rubenf
rubenf3w ago
you will need to ping all requirements but yes (so wmill too)
Devon
DevonOP3w ago
maybe a dumb question but im an intern and windmill is new for me where can i see what version of windmill we are running?
Pyra
Pyra3w ago
I believe not. The library you are trying to pin (https://pypi.org/project/docx/) is not maintained since 2014 and been moved to another project. The more up-to-date version would be https://pypi.org/project/python-docx/
Devon
DevonOP3w ago
in the example it still says: from docx import Document The thing is i cant do pip install from the web IDE
Pyra
Pyra3w ago
yes, both docx and python-docx have the same module called docx that you can import. python-docx is newer project and I believe naming was chosen for better compatibility for people who migrate from docx to python-docx. Just try this:
# requirements:
# python-docx

from docx import Document
# requirements:
# python-docx

from docx import Document
Devon
DevonOP3w ago
I think that works as now its complaining about my import wmill line
rubenf
rubenf3w ago
Please read the docs and try to understand what #requirements: does
Devon
DevonOP3w ago
It works, thanks for helping me.

Did you find this page helpful?