Come installare Python per eseguire Aspose.Words per Python tramite .NET

Questo tutorial fornisce passaggi dettagliati su come installare Python per eseguire Aspose.Words per Python tramite .NET. Presuppone che tu abbia configurato .NET Framework in uno qualsiasi dei sistemi basati su Microsoft Windows, macOS o Linux e ti guida a installare tutto il software necessario per eseguire il codice Aspose.Words in Python. Installerai Python durante questi passaggi e creerai un nuovo file DOCX per verificare l’ambiente stabilito.

Passaggi per installare Python per eseguire Aspose.Words per Python tramite .NET

  1. Si presuppone che tu abbia un sistema operativo Microsoft Windows, macOS o Linux configurato con il supporto .NET Framework. Per maggiori informazioni puoi visitare Install .NET on Windows, Linux, and macOS
  2. Installa Python 3.9.6
  3. Installa il comando Pip
  4. Installa Aspose.Words for Python via .NET utilizzando Pip
  5. Scrivere ed eseguire il codice Aspose.Words per Python per creare un file Word

Se disponi di un ambiente che soddisfa i primi due passaggi, puoi ignorarli ed eseguire i comandi successivi nel terminale o nel prompt dei comandi all’interno del tuo ambiente Linux, Windows o macOS. Devi installare Python e Pip3 per installare Aspose.Words.

Script per installare Python per eseguire Aspose.Words per Python tramite .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

Se hai già configurato l’ambiente .NET, Python 3.9.6 e PIP, puoi iniziare dal passaggio 4 e proseguire per utilizzare l’API. Si consiglia di utilizzare Python 3.9.6 con API invece del vecchio Python2.x.

Viene fornito anche un codice di esempio di base funzionante che utilizza l’API per verificare l’installazione. Puoi provare altri esempi ed esplorare le funzionalità dell’API per produrre i diversi esempi che desideri produrre utilizzando l’API.

 Italiano