How to Install Python to Run Aspose.Words for Python via .NET

This tutorial provides detailed steps on how to install python to run Aspose.Words for Python via .NET. It assumes that you have .NET Framework configured in any of Microsoft Windows, macOS or Linux based systems and guides you to install all the necessary software required to run Aspose.Words code in Python. You will install Python during these steps and create a new DOCX file to verify the established environment.

Steps to Install Python to Run Aspose.Words for Python via .NET

  1. It is assumed that you have a Microsoft Windows, macOS or Linux configured with .NET framework support. For more information you can visit, Install .NET on Windows, Linux, and macOS
  2. Install Python 3.9.6
  3. Install Pip command
  4. Install Aspose.Words for Python via .NET using Pip
  5. Write and run the Aspose.Words for Python code to create a Word file

If you have an environment satisfying first two steps, you can ignore them and execute the subsequent commands in the terminal or command prompt inside your Linux, Windows or macOS environment. You need to install Python and Pip3 to install Aspose.Words.

Script to Install Python to Run Aspose.Words for Python via .NET

1. Install .NET Framework (Required for Ubuntu only)
#For Ubuntu
apt update
apt upgrade
apt install sudo
sudo apt update
sudo apt install wget
wget -q https://packages.microsoft.com/config/ubuntu/19.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
sudo apt-get update
sudo apt-get install apt-transport-https
sudo apt-get update
sudo apt-get install dotnet-sdk-3.1
2. Install Python 3.9.6
#For Ubuntu
sudo apt install -y python3.9
# For MS Windows and macOS
install using MSI or DMG package. Be sure to select the check box to set the path during installation
2. Installing Pip Command
# For Ubuntu
sudo apt install python3-pip
# For Windows and Mac
python3 -m pip install --upgrade pip
3. Install Aspose.Words
python3 -m pip install aspose-words
# Additional requirements for Ubuntu to install libgdiplus and libc6-dev
# For Ubuntu only
apt-get update
apt-get install -y libgdiplus
cd /usr/lib && ln -s libgdiplus.so gdiplus.dll
apt-get install -y --no-install-recommends libc6-dev
4. Write Sample Program and save It As SampleWord.Py And Run Program
python3 SampleWord.py
import aspose.words as aw
doc = aw.Document()
builder = aw.DocumentBuilder(doc)
builder.write("Hello world!")
doc.save("c:\\words\\out.docx")
5. Run the sample using following command
python3 SampleWord.py

If you already have .NET, Python 3.9.6 and PIP environment setup, you can start from Step 4 and onward to use the API. It is suggested to use Python 3.9.6 with API instead of older Python2.x.

A working basic sample code using the API is also given to verify the installation. You can try other samples and explore the API features to produce the different examples you want to produce using the API.

 English