How to Install Python to Run Aspose.Barcode for Python via Java

This tutorial provides detailed steps on how to install python to run Aspose.Barcode for python via java. It assumes that you have installed Docker on your system and guides you to install all the necessary software required to run Aspose.Barcode code in Python. You will install Python during these steps and create a new Barcode image to verify the established environment.

Steps to Install Python to Run Aspose.Barcode for Python via Java

  1. Using docker command pull the latest image of Ubuntu
  2. Run the Ubuntu image using the docker command
  3. Install Sudo command
  4. Install Java
  5. Install Python
  6. Install Pip command
  7. Install Aspose.Barcode for Python via Java and JPype1
  8. Install Pillow imaging library using Pip
  9. Write and run the Aspose.BarCode for Python code to create a Barcode

Note that these steps assume that you are using Docker to test the complete environment however if you do not want to use Docker, you can ignore the initial first two steps and execute the rest of the commands in the terminal or command prompt in your Linux, Windows or Mac environment. You need to install Python and Pip3 to install Aspose.Barcode, JPype1 and Pillow libraries for running the sample code given at the end of the following script.

Script to Install Python to Run Aspose.Barcode for Python via 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

If you already have Sudo, Java and Python3 environment setup, you can start from Step 6 and onward to use the API. It is suggested to use Python3 with API instead of older Python2.x.

A working basic sample code using the API is also given to verify the installation. You can commit changes in your docker container and only need to perform step 9 for a different example you want to produce using the API.

 English