Questo tutorial fornisce passaggi dettagliati su come installare python per eseguire Aspose.Slides per Python tramite .NET. Si presume che tu abbia .NET Framework configurato in qualsiasi sistema basato su Microsoft Windows, macOS o Linux e ti guida a installare tutto il software necessario per eseguire il codice Aspose.Slides in Python. installeremo Python durante questi passaggi e creeremo un nuovo file PPTX per verificare l’ambiente stabilito.
Passaggi per installare Python per eseguire Aspose.Slides per Python tramite .NET
- Si presume che tu abbia un Microsoft Windows, macOS o Linux configurato con il supporto di .NET Framework. Per ulteriori informazioni puoi visitare Install .NET on Windows, Linux, and macOS
- Installa l’estensione Python in VS Code
- Installa Python 3.9.6
- Installa il comando Pip
- Installa Aspose.Slides for Python via .NET
- Scrivi il codice ed esegui il codice Aspose.Slides per Python per creare un file PowerPoint
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.Slides.
Script per installare Python per eseguire Aspose.Slides 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 | |
3. Installing Pip Command | |
# For Ubuntu | |
sudo apt install python3-pip | |
# For Windows and Mac | |
python3 -m pip install --upgrade pip | |
4. Install Aspose.Slides | |
python3 -m pip install aspose-slides | |
# 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 | |
5. Write Sample Program and save It As SamplePresentation.Py And Run Program | |
python3 SamplePresentation.py | |
import aspose.slides as slides | |
# Instantiate a Presentation object that represents a presentation file | |
with slides.Presentation() as presentation: | |
slide = presentation.slides[0] | |
slide.shapes.add_auto_shape(slides.ShapeType.LINE, 50, 150, 300, 0) | |
presentation.save("NewPresentation.pptx", slides.export.SaveFormat.PPTX) | |
6. Run the sample using following command | |
python3 SamplePresentation.py |
Se hai già la configurazione dell’ambiente .NET, Python 3.9.6 e PIP, puoi iniziare dal passaggio 4 in poi per utilizzare l’API. Si suggerisce 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 campioni ed esplorare le funzionalità dell’API per produrre i diversi esempi che desideri produrre utilizzando l’API.