Python installeren om Aspose.Slides voor Python uit te voeren via .NET

Deze zelfstudie biedt gedetailleerde stappen voor het installeren van python om Aspose.Slides voor Python uit te voeren via .NET. Er wordt van uitgegaan dat u .NET Framework hebt geconfigureerd in een van Microsoft Windows, macOS of Linux gebaseerde systemen en begeleidt u bij het installeren van alle benodigde software die nodig is om Aspose.Slides-code in Python uit te voeren. Tijdens deze stappen installeren we Python en maken we een nieuw PPTX-bestand om de bestaande omgeving te verifiëren.

Stappen om Python te installeren om Aspose.Slides voor Python uit te voeren via .NET

  1. Er wordt van uitgegaan dat je een Microsoft Windows, macOS of Linux hebt geconfigureerd met .NET framework-ondersteuning. Voor meer informatie kunt u terecht op Install .NET on Windows, Linux, and macOS
  2. Installeer de Python-extensie in VS Code
  3. Installeer Python 3.9.6
  4. Pip-opdracht installeren
  5. Installeer Aspose.Slides for Python via .NET
  6. Schrijf code en voer de Aspose.Slides voor Python-code uit om een PowerPoint-bestand te maken

Als je een omgeving hebt die voldoet aan de eerste twee stappen, kun je deze negeren en de volgende opdrachten uitvoeren in de terminal of opdrachtprompt in je Linux-, Windows- of macOS-omgeving. U moet Python en Pip3 installeren om Aspose.Slides te installeren.

Script om Python te installeren om Aspose.Slides voor Python uit te voeren 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
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

Als u al een .NET-, Python 3.9.6- en PIP-omgeving hebt ingesteld, kunt u vanaf stap 4 en verder beginnen om de API te gebruiken. Er wordt voorgesteld om Python 3.9.6 met API te gebruiken in plaats van het oudere Python2.x.

Er wordt ook een werkende basisvoorbeeldcode met behulp van de API gegeven om de installatie te verifiëren. U kunt andere voorbeelden proberen en de API-functies verkennen om de verschillende voorbeelden te produceren die u met de API wilt maken.

 Nederlands