I’m new to Python, so please bare with me. I would like to use python-docx within Dynamo to be able (or try) to write to a Word document.
I went on the website for it and it explains how to install it using pip install but I don’t know how that works in IronPython through Dynamo or if it’s possible to use in Dynamo.
I’ve installed python-docx and lxml (a dependency) in a local folder but I don’t know how to access it.
So far I’ve tried this code but it can’t seem to get the library.
import clr
import sys
sys.path.append(r’[local path where python-docx is installed]')
Is there something I’m missing when it comes to Python packages? Does it need to be put in a specific spot?
You can run external commands like scripts or executables from Dynamo. You can parse your data from Revit to Dynamo and then run a Python script from outside Revit and Dynamo. You can run Python with every library you need and both Python 2.x and 3.x
Take a look at this.
A Python script from inside Dynamo can run any arbitrary external command. You can run any shell script or executable. There’s no problem in installing stand alone Python 3.x or whatever version docx library needs and run external Python script within that environment.
To wrap up.
Install stand alone Python.
Install all required libraries.
Create a .py script on your computer.
Call your script from Dynamo
I don’t know if OP works alone or in corporate environment. His problem is solvable but not sustainable.
Yes, it seems this package is supported with IronPython 2.7.3. I made sure of that.
The thing is I have the package downloaded and unzipped, but how do I use the setup.py to install the package and get the init.py file?
I probably should’ve included that in the original post.
Also, I’m in an office and would like to put it in a shared drive location that other people could access. Does it have to go C:\Program Files (x86)\IronPython 2.7\Lib?
Thanks so much for the help!
Okay I see what you mean then. That’s convenient!
I guess it’s the package download that’s confusing me. After unzipping the package, it gave me a folder with the name of the package and setup.py, but I don’t know if that’s the actual package.
Do I run the setup.py somehow or place that in that folder?
How do I run that? Is that done through IronPython? Does that make sense?
Okay that’s what I needed. I didn’t realize I’d have to install Python, I figured I could go through IronPython but this sounds like a more straight-forward route. I’ll give it a try. Thank you so much!
import sys
print(sys.version)
print('Number of arguments:', len(sys.argv), 'arguments.')
print('Argument List:', str(sys.argv))
input('Press Enter to continue...')