วิธีการติดตั้ง Python เพื่อเรียกใช้ Aspose.Barcode สำหรับ Python ผ่าน Java

บทช่วยสอนนี้มีขั้นตอนโดยละเอียดเกี่ยวกับวิธี ติดตั้ง python เพื่อเรียกใช้ Aspose.Barcode สำหรับ python ผ่าน java จะถือว่าคุณได้ติดตั้ง Docker บนระบบของคุณแล้ว และแนะนำคุณให้ติดตั้งซอฟต์แวร์ที่จำเป็นทั้งหมดที่จำเป็นสำหรับการรันโค้ด Aspose.Barcode ใน Python คุณจะ ติดตั้ง Python ในระหว่างขั้นตอนเหล่านี้ และสร้างอิมเมจ Barcode ใหม่เพื่อยืนยันสภาพแวดล้อมที่สร้างขึ้น

ขั้นตอนการติดตั้ง Python เพื่อรัน Aspose.Barcode สำหรับ Python ผ่าน Java

  1. ใช้คำสั่ง docker ดึงอิมเมจล่าสุดของ Ubuntu
  2. เรียกใช้อิมเมจ Ubuntu โดยใช้คำสั่ง docker
  3. ติดตั้งคำสั่ง Sudo
  4. ติดตั้งจาวา
  5. ติดตั้งไพธอน
  6. ติดตั้งคำสั่ง Pip
  7. ติดตั้ง Aspose.Barcode for Python via Java และ JPype1
  8. ติดตั้งไลบรารีรูปภาพ Pillow โดยใช้ Pip
  9. เขียนและรันโค้ด Aspose.BarCode สำหรับ Python เพื่อสร้างบาร์โค้ด

โปรดทราบว่าขั้นตอนเหล่านี้ถือว่าคุณกำลังใช้ Docker เพื่อทดสอบสภาพแวดล้อมทั้งหมด อย่างไรก็ตาม หากคุณไม่ต้องการใช้ Docker คุณสามารถข้ามสองขั้นตอนแรกเริ่มต้นและดำเนินการคำสั่งที่เหลือในเทอร์มินัลหรือพรอมต์คำสั่งใน Linux ของคุณ สภาพแวดล้อม Windows หรือ Mac คุณต้อง ติดตั้ง Python และ Pip3 เพื่อติดตั้ง Aspose.Barcode, JPype1 และไลบรารี่หมอน สำหรับการเรียกใช้โค้ดตัวอย่างที่ระบุในตอนท้ายของสคริปต์ต่อไปนี้

สคริปต์สำหรับติดตั้ง Python เพื่อเรียกใช้ Aspose.Barcode สำหรับ Python ผ่าน Java

1. Load the latest Ubuntu Image
docker pull ubuntu
2. Run Ubuntu Image Using Docker Command
docker run -it ubuntu
3. Install Sudo Command
apt update
apt upgrade
apt install sudo
sudo apt update
4. Install Java Runtime environment
sudo apt install default-jre
5. Install Python3
sudo apt update
sudo apt upgrade
sudo apt install -y python3
6. Installing Pip Command
sudo apt update
sudo apt install python3-pip
7. Install Aspose.Barcode
pip install aspose-barcode-for-python-via-java
pip install JPype1
8. Install Pillow imaging library
pip install Pillow
9. Write Sample Program and save It As SampleBarcode.Py And Run Program
python3 SampleBarcode.py
SAMPLE CODE TO BE WRITTEN IN SampleBacrode.Py
from asposebarcode import Generation
# Create an object of BarCodeGenerator class
# Specify Barcode Encode Type as QR
encode_type = Generation.EncodeTypes.QR
GenerateQRCode = Generation.BarcodeGenerator(encode_type, None)
# Set QR code text to be encoded as generated QR code
GenerateQRCode.setCodeText("Python Test QR")
#BarCodeImageFormat.PNG.value
file_path = "QR_Code.png"
imageFormat= Generation.BarCodeImageFormat(3)
# Saving the QR code in PNG image format
GenerateQRCode.save(file_path, imageFormat)
10. Run the sample using following command
python3 SampleBarcode.py

หากคุณมีการตั้งค่าสภาพแวดล้อม Sudo, Java และ Python3 อยู่แล้ว คุณสามารถเริ่มจากขั้นตอนที่ 6 เป็นต้นไปเพื่อใช้ API ขอแนะนำให้ใช้ Python3 กับ API แทน Python2.x ที่เก่ากว่า

โค้ดตัวอย่างพื้นฐานที่ใช้งานได้โดยใช้ API จะได้รับเพื่อตรวจสอบการติดตั้งด้วย คุณสามารถยอมรับการเปลี่ยนแปลงในคอนเทนเนอร์นักเทียบท่าและต้องทำขั้นตอนที่ 9 สำหรับตัวอย่างอื่นที่คุณต้องการสร้างโดยใช้ API

 ไทย