Can’t Install “pip install docxtpl”

Jerry PM
5 min readDec 4, 2023


python pip cannot install

Source: author

Introduce the problem where users are unable to install the docxtpl package using pip. Explain that docxtpl is a Python library used for creating Microsoft Word (.docx) documents from templates.

Common Causes and Solutions

Cause 1: Python/Pip Not Installed or Outdated

  • Explanation: Users might not have Python or pip installed, or they may be using outdated versions.
  • Solution: Guide on checking Python and pip versions and instructions for installation or updating.

Cause 2: Incorrect Command Syntax

  • Explanation: Typographical errors in the command can lead to installation failure.
  • Solution: Provide the correct command syntax and common mistakes to avoid.

Cause 3: Network Issues

  • Explanation: Issues with the user’s network connection can prevent pip from accessing the Python Package Index (PyPI).
  • Solution: Tips for troubleshooting network issues and using alternative network settings.

Download Python new version here

In my case, this is how I solved the issue

  1. Check the Python version using “python3 — version”
➜  INVOICE_GENERATOR: python3 --version
Python 3.12.0

2. Next step check if “pip” is available “python3 -m ensurepip”

➜  INVOICE_GENERATOR python3 -m ensurepip
Looking in links: /var/folders/b3/rc8zqms11jb8565d5mp5wbfw0000gp/T/tmpypo78civ
Requirement already satisfied: pip in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (23.2.1)

3. After I find the file there now I can run the “pip” install just add “3” after pip

➜  INVOICE_GENERATOR pip3 install docxtpl
Collecting docxtpl
Downloading docxtpl-0.16.7-py2.py3-none-any.whl (28 kB)
Collecting six (from docxtpl)
Downloading six-1.16.0-py2.py3-none-any.whl (11 kB)
Collecting python-docx (from docxtpl)
Obtaining dependency information for python-docx from
Downloading python_docx-1.1.0-py3-none-any.whl.metadata (2.0 kB)
Collecting docxcompose (from docxtpl)
Downloading docxcompose-1.4.0.tar.gz (20 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Collecting jinja2 (from docxtpl)
Downloading Jinja2-3.1.2-py3-none-any.whl (133 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 133.1/133.1 kB 1.2 MB/s eta 0:00:00
Collecting lxml (from docxtpl)
Obtaining dependency information for lxml from
Downloading lxml-4.9.3-cp312-cp312-macosx_11_0_universal2.whl.metadata (3.8 kB)
Collecting setuptools (from docxcompose->docxtpl)
Obtaining dependency information for setuptools from
Using cached setuptools-69.0.2-py3-none-any.whl.metadata (6.3 kB)
Collecting babel (from docxcompose->docxtpl)
Obtaining dependency information for babel from
Downloading Babel-2.13.1-py3-none-any.whl.metadata (1.6 kB)
Collecting typing-extensions (from python-docx->docxtpl)
Obtaining dependency information for typing-extensions from
Downloading typing_extensions-4.8.0-py3-none-any.whl.metadata (3.0 kB)
Collecting MarkupSafe>=2.0 (from jinja2->docxtpl)
Obtaining dependency information for MarkupSafe>=2.0 from
Downloading MarkupSafe-2.1.3-cp312-cp312-macosx_10_9_x86_64.whl.metadata (2.9 kB)
Downloading python_docx-1.1.0-py3-none-any.whl (239 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 239.6/239.6 kB 2.3 MB/s eta 0:00:00
Downloading lxml-4.9.3-cp312-cp312-macosx_11_0_universal2.whl (8.6 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 8.6/8.6 MB 4.3 MB/s eta 0:00:00
Downloading MarkupSafe-2.1.3-cp312-cp312-macosx_10_9_x86_64.whl (13 kB)
Downloading Babel-2.13.1-py3-none-any.whl (10.1 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 10.1/10.1 MB 4.6 MB/s eta 0:00:00
Using cached setuptools-69.0.2-py3-none-any.whl (819 kB)
Downloading typing_extensions-4.8.0-py3-none-any.whl (31 kB)
Building wheels for collected packages: docxcompose
Building wheel for docxcompose (pyproject.toml) ... done
Created wheel for docxcompose: filename=docxcompose-1.4.0-py3-none-any.whl size=23267 sha256=2ae2d79bb089cc9fe16dabcc70138be5667b3b064ff15256b6a83daad0896cf9
Stored in directory: /Users/jerry/Library/Caches/pip/wheels/d4/41/77/fea002cfe3f6bf960d7be78eb8feb1147bc6a862021c627c34
Successfully built docxcompose
Installing collected packages: typing-extensions, six, setuptools, MarkupSafe, lxml, python-docx, jinja2, babel, docxcompose, docxtpl
Successfully installed MarkupSafe-2.1.3 babel-2.13.1 docxcompose-1.4.0 docxtpl-0.16.7 jinja2-3.1.2 lxml-4.9.3 python-docx-1.1.0 setuptools-69.0.2 six-1.16.0 typing-extensions-4.8.0

[notice] A new release of pip is available: 23.2.1 -> 23.3.1
[notice] To update, run: python3.12 -m pip install --upgrade pip

Optional pip update

When you run pip3 install --upgrade pip, it will connect to the Python Package Index (PyPI) and download the latest version of the pip tool. This can be useful to ensure that you have the most up-to-date version of pip with bug fixes and new features. Keeping pip updated is often recommended to ensure smooth and reliable package management in your Python environment.

➜  INVOICE_GENERATOR pip3 install --upgrade pip
Requirement already satisfied: pip in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (23.2.1)
Collecting pip
Obtaining dependency information for pip from
Downloading pip-23.3.1-py3-none-any.whl.metadata (3.5 kB)
Downloading pip-23.3.1-py3-none-any.whl (2.1 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.1/2.1 MB 2.0 MB/s eta 0:00:00
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 23.2.1
Uninstalling pip-23.2.1:
Successfully uninstalled pip-23.2.1

After installing docxtpl and you found this warning, here is how to fix that

⚠️ Import “docxtpl” could not be resolved”

Using “quickfix” -> “Select a different interpreter -> “pyhton{_version}

Using “docxtp” is just to show how to fix the issue
Using “docxtp” is just to show how to fix the issue

Ignoring “docxtp” is not because there is a missing character, which should be “L,” it should be “docxtpl.” This is just an example of how I can fix this issue.

If Error in “tkcalendar”

This is to fix the issue

  • Open your terminal or command prompt.
  • Ensure that pip is up to date by running the following command
$ python3 -m pip install --upgrade pip
  • Install the tkcalendar package by running:
$ python3 -m pip install tkcalendar
  • Now running python code

Here I added installing py2app

This is for making your code can be using just run app.

$ sudo pip3 install py2app

here is the link for py2app. after installing py2app, create a new file name

from setuptools import setup

APP = ['']
'argv_emulation': True,
'packages': ['required', 'packages', 'if_any'],

options={'py2app': OPTIONS},

And then running in the terminal this syntax

$ python py2app

The next step in installing Flask just to use “pip install flask”


Why my code is error? Because wrong to use a “pip” just add “3” behind the “pip.

// Wrong
$ pip install docxtpl
// Correct
$ pip3 install docxtpl
Photo by Caspar Camille Rubin on Unsplash

Transform Your Ideas into Reality with Expert iOS & Flutter Development! 🚀 Are you looking to bring your app concept to life? I specialize in crafting exceptional iOS and Flutter applications that stand out in the digital world. Let’s collaborate to turn your vision into a stunning, functional app. Contact me today to start your app development journey!”

Hire me ->