0

I am completely new to Python. I am watching a guide on creating Data Entry Forms for Word. The guide has instructed me to install docxtpl pip install docxtpl

First question: Where dit it install this? Where can I find these files now?

Next instructions were to from pathlib import Path from docxtpl import DocxTemplate

I assume running this enables me to use commands 'Path' and 'Docxtemplate' from the docxtpl package. (It's a package, right? And these are commands?)

Next up - and here is where my Jupyter Notebook returns 'invalid syntax': document_path = Path(C:\Users*pathing*\Python_template_BvW.docx).parent / "Python_template_BvW.docx"

I get that I am linking the text document_path to a value - and that the value here is the Path to the parent directory of my template Word file, the file I will later on create a data entry form for. However I get: File "", line 1 document_path=Path(C:\Users*pathing*\Data_Entry_for_Word\Python_template_BvW.docx).parent / "Python_template_BvW.docx" ^ SyntaxError: invalid syntax

Please, help. Why is the Syntax wrong? I've completely copied the guide so far.

Thank you for your advice and help.

Kind regards, Nicolas

1 Answers1

0

Files are installed under your python interpreter and can be found like so:

import ocxtpl
print(docxtpl.__file__)

How to retrieve a module's path?

The syntax is invalid because you are missing "" around the path. You also want to input it as a raw string to ignore the escapes, i.e.

document_path = Path(r"C:\Users*pathing*\Python_template_BvW.docx").parent / "Python_template_BvW.docx"
Tzane
  • 2,752
  • 1
  • 10
  • 21