Spire.Doc for Python is a robust library that enables you to read and write Microsoft Word documents using Python. With Spire.Doc, you can create, read, edit, and convert both DOC and DOCX file formats without requiring Microsoft Word to be installed on your system.

This article demonstrates how to install Spire.Doc for Python on Mac.

Step 1

Download the most recent version of Python for macOS and install it on your Mac. If you have already completed this step, proceed directly to step 2.

How to Install Spire.Doc for Python on Mac

Step 2

Open VS Code and search for 'Python' in the Extensions panel. Click 'Install' to add support for Python in your VS Code.

How to Install Spire.Doc for Python on Mac

Step 3

Click 'Explorer' > 'NO FOLRDER OPENED' > 'Open Folder'.

How to Install Spire.Doc for Python on Mac

Choose an existing folder as the workspace, or you can create a new folder and then open it.

How to Install Spire.Doc for Python on Mac

Add a .py file to the folder you just opened and name it whatever you want (in this case, HelloWorld.py).

How to Install Spire.Doc for Python on Mac

Step 4

Use the keyboard shortcut Ctrl + ' to open the Terminal. Then, install Spire.Doc for Python by entering the following command line in the terminal.

pip3 install spire.doc

Note that pip3 is a package installer specifically designed for Python 3.x versions, while pip is a package installer for Python 2.x versions. If you are working with Python 2.x, you can use the pip command.

How to Install Spire.Doc for Python on Mac

Step 5

Open a Terminal window on your Mac, and type the following command to obtain the installation path of Python on your system.

python3 -m pip --version

How to Install Spire.Doc for Python on Mac

Find the libSkiaSharp.dylib file under the site-packages/spire/doc/lib folder. The full path in this case is /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/spire/doc/lib/libSkiaSharp.dylib

How to Install Spire.Doc for Python on Mac

Copy the libSkiaSharp.dylib file into the folder where your .py file is located.

How to Install Spire.Doc for Python on Mac

Step 6

Add the following code snippet to the 'HelloWorld.py' file.

  • Python
from spire.doc.common import *
from spire.doc import *

document = Document()
section = document.AddSection()
paragraph = section.AddParagraph()
paragraph.AppendText("Hello World")
document.SaveToFile("HelloWorld.docx", FileFormat.Docx2019)
document.Dispose()

How to Install Spire.Doc for Python on Mac

After executing the Python file, you will find the resulting Word document in the 'EXPLORER' panel.

How to Install Spire.Doc for Python on Mac

Published in Getting Started

Spire.Doc for Python is a Python library for reading, creating, editing and converting Word (.doc & .docx) files in any Python application. This article shows you how to install Spire.Doc for Python on Windows.

Step 1

Download the latest version of Python and install it on your computer. If you have already installed it, skip to step 2.

How to Install Spire.Doc for Python in VS Code

Step 2

Click "Extensions" in VS Code, search for "Python" and then install it.

How to Install Spire.Doc for Python in VS Code

Step 3

Click "Explorer" - "NO FOLRDER OPENED" - "Open Folder".

How to Install Spire.Doc for Python in VS Code

Choose an existing folder as the workspace, or you can create a new folder and then select it.

How to Install Spire.Doc for Python in VS Code

Add a .py file to the folder you just added (Python folder in this case), and name it whatever you like.

How to Install Spire.Doc for Python in VS Code

Step 4

Click "Terminal" and then "New Terminal".

How to Install Spire.Doc for Python in VS Code

Input the following pip command to install Spire.Doc for Python and plum-dispatch v1.7.4.

pip install Spire.Doc

How to Install Spire.Doc for Python in VS Code

Alternatively, you can download Spire.Doc for Python from our website,  and unzip it to get two .whl files from the "lib" folder. They're for Linux and Windows systems, respectively.

How to Install Spire.Doc for Python in VS Code

Then, install Spire.Doc for Python and plum-dispatch v1.7.4 by running the following commands.

pip install E:\Library\Python\spire.doc.python_11.8.0\lib\Spire.Doc_for_Python-11.8.0-py3-none-win_amd64.whl

How to Install Spire.Doc for Python in VS Code

Step 5

Add the following code snippet to the "HelloWorld.py" file.

  • Python
from spire.doc.common import *
from spire.doc import *

document = Document()
section = document.AddSection()
paragraph = section.AddParagraph()
paragraph.AppendText("Hello World!")
document.SaveToFile("output.docx", FileFormat.Docx)
document.Close()

How to Install Spire.Doc for Python in VS Code

Once you run the Python file, you'll see the result Word document in the "EXPORER" panel.

How to Install Spire.Doc for Python in VS Code

Published in Getting Started