The QPath Blog

Developing in QuantumPath® with Python: Selecting the development environment
To exploit the advantages of quantum computing, tools are needed. Tools that provide specialists with high-level communication channels with the technology that encapsulate the deepest details of the system and allow them to focus on the problem to be solved. QuantumPath® is a platform that provides multiple tools to make this possible. Its execution engine offers from a visual system that assists the specialist in the design of quantum applications to the most extreme automation through programming SDKs. And always with a clear core principle: to be vendor agnostic[1]. And they apply both to quantum technology and to the programming language to be used for it.
qSOA®[2] is the interface technology that allows to talk to QuantumPath® using open interfaces. A set of calls that, supported by massively adopted technologies such as the REST API, make it possible to create as many SDKs as multiple programming languages capable of accessing communications APIs.
In this article, we will focus on the Python language. Of the many advantages of this programming language, we will focus on its accessibility, its very high level, and its great versatility, since it can be executed in a large number of environments under different configurations adapted to the user’s needs.
The QPath® PySDK is offered in QuantumPath®. This SDK, as a Python package, enables dialogue with the QuantumPath® CORE using the Python programming language. This makes it possible both to execute pre-designed use cases with the platform and to create new ones dynamically or, why not, to analyze their evolution over time. This opens the possibility of creating all types of client applications that consume quantum services (from console to web applications).
As part of the QuantumPath® agnosticism advantage, to work with any supported quantum provider, we will only need the QPath® PySDK Python package. Nothing else. It will not be necessary to have Qiskit, Leap, or any other quantum provider available on the same computer. Just the QPath® SDK. This reduces the complexity of setting up the development environment and eliminates the potential conflicts of keeping all that vendor ecosystem in one place.
Although there are many alternatives on the market for working with Python professionally, in this article we will focus on two different environments with which to work with QuantumPath® for the development and life cycle management of classic software using Python. Because of its free availability and massive use. For the case that concerns us, the development environment is just an intermediary between the code written by the developer and the functions offered by QuantumPath® through qSOA®. That said, we are going to show the configurations of two different environments, of the many that exist to work, from 0 with QuantumPath® and its PySDK. We are talking about Conda and Visual Studio Code. Even though it is assumed that there is already a version of Python in the system, the development environments themselves offer functionalities to obtain what is necessary once installed. Otherwise, Python can be downloaded from its official website and we will always recommend the latest version.
First environment configuration: Conda
Conda is a very useful and versatile tool for managing Python environments and packages. It allows you to create and manage virtual environments independently from the overall Python installation. Here are the 5 steps required to create and configure a Conda environment from scratch and start using the QuantumPath® Python SDK.
Step 1: Download and install Anaconda
To create a Conda environment it is necessary to install a Python distribution that includes it. In this case, we are going to use one of the most popular ones: Anaconda.
The steps to proceed are as described below:
1. Download Anaconda from its official website for the operating system we are using: Windows, macOS, or Linux.
Run the downloaded installer and follow its instructions.

Figure 1. Anaconda Installation
Step 2: Create and activate Anaconda environment (optional)
In case you want to work with a new Python environment to make sure there are no incompatibilities between packages, you can create a new Conda environment. This is completely optional, otherwise, you will work on the default Python environment.
The steps to create a Conda environment and activate it are:
1. Open the Anaconda Prompt application that was automatically installed in the previous step along with the Anaconda environment.
2. Create a new environment with: conda create –name environment_name python=x.x
Replacing “environment_name” by the name you want to give to your environment, and “x.x” by the version of Python you want to use. In this case, it would look like this:

Figure 2. Conda environment creation
1. After preparation of the environment deployment, activate the created environment using: conda activate environment_name
Following the example would be:

Figure 3. Conda environment activation
1. The activated environment can be displayed using: conda env list and the activated environment is marked with an asterisk (*) after its name. As well as there are multiple commands to manage them. Of course, these same operations can be performed with the Conda visual environment.
Step 3: Instal QuantumPath® Python SDK
Once you have created and activated the Conda environment on which you will work, you can install the packages you want to use through the PyPI package repository.
To install the QuantumPath® Python SDK, type: pip install QuantumPathQSOAPySDK

Figure 4. QuantumPath qSOA PySDK Installation
Only with the installation of this package, you will be able to make use of all the features of QuantumPath® without the need to install the rest of the SDKs of the different manufacturers. All this is handled internally by QuantumPath®.
Step 4: Create Jupyter Notebook
Once the entire Conda environment is configured and the QuantumPath® SDK is installed, to open the Jupyter interface, you must go to the Anaconda Navigator application. As several Python environments are available, it may be necessary to install the jupyter packages. In order not to exceed the procedure, all this can be done both from the console and from the Anaconda UI.

Figure 5. Anaconda Navigator
Once the environment is selected and clicked on the Jupyter Notebook application, the web browser we use will open. We take the opportunity to create a custom directory and we go to the path where we want to create our Jupyter Notebook to work, and click on “New” and “Python 3” to create a new one.

Figure 6. Jupyter Notebook creation
Step 5: Working with QuantumPath® PySDK
After these steps, the web interface for working with the created Jupyter Notebooks will be displayed. As it is already known, it follows a cell system where you execute lines of code individually.
To work with the QuantumPath® SDK, simply import the library, and you can make use of its functionalities by adding cells with the “+” button, clicking on one of them, and pressing the “Run” button to execute its code.

Figure 7. Using the SDK on a Jupyter Notebook
Once we have the environment ready, we recommend downloading from the qSOA® portal, the QuantumPath® quick start notebooks to start working on them as well as experimenting with the tutorials to be productive as soon as possible.

Figure 8. qSOA® Portal
First environment configuration: Visual Studio Code
Visual Studio Code is a widely used development environment that offers excellent integration with Python and its use through Jupyter Notebooks. Here are the steps required to get started from scratch with Visual Studio Code and use the QuantumPath® Python SDK for developing quantum solutions.
Step 1: Download and install Visual Studio Code
The first step is to have a version of the IDE (Integrated Development Environment) Visual Studio Code. This will allow us to develop our Python code and make some of the QuantumPath® functions using Jupyter Notebooks.
The steps to be followed are:
1. Download Visual Studio Code from its official website for the operating system we are using: Windows, macOS, or Linux.
2. Run the downloaded installer and follow its instructions.

Figure 9. Visual Studio Code Installation
Step 2: Install Python and Jupyter Notebook
To work with Python and Jupyter Notebooks in Visual Studio Code, it is necessary to install a set of extensions.
To do it, the steps to follow are:
Go to the extensions section of Visual Studio Code.

Figure 10. Extensions Marketplace
1. Type in the extensions search engine “Python” and install the first result verified by Microsoft.

Figure 11. Installation of the Python extension
1. Type in the extensions search engine “Jupyter” and install the first result verified by Microsoft.

Figure 12. Jupyter extension installation
Step 3: Create Jupyter Notebook
Once Visual Studio Code, the Python environment, and the QuantumPath® SDK are configured, proceed to create a Jupyter Notebook using the following steps:
1. Click on the “File” tab, “Open Folder”, and select the folder where we are going to work.

Figure 13. Work folder selection
Click on the marked icon to create a new file, to which you must give the name you want for the Jupyter Notebook and the extension .ipynb

Figure 14, Jupyter Notebook creation
Step 4: Create and activate a virtual environment (optional)
In case you want to work with a new Python environment to make sure there are no incompatibilities between packages, you can create a new virtual environment. This is completely optional, otherwise, you will work on the default Python environment.
The steps to create a virtual environment and activate it are as follows:
1. Click on “Select Kernel” to select the environment on which you will work.

Figure 15. Select Kernel
1. Click on “Python Environments”.

Figure 16. Python Environments
1. The available environments are displayed, from which we can choose the predefined Python environment or create a new one by clicking on “Create Python Environment”.

Figure 17. Select another Kernel
1. Click on “Venv”.

Figure 18. Create a virtual environment
1. Click on the version of Python you want to use.

Figure 19. Python version selection
1. The virtual environment will be created in the folder and will be selected as Kernel.

Figure 20. Virtual environment created and activated
Step 5: Install QuantumPath® Python SDK
Once the virtual environment on which you will work has been created and activated, you can install the packages you want to use through the PyPI package repository.
To install the QuantumPath® Python SDK, type in the first cell: pip install QuantumPathQSOAPySDK and execute it by clicking on the button on the left. Finally, click on “Restart” to restart the Kernel and update its libraries.

Figure 21. QuantumPath qSOA PySDK Installation
Only with the installation of this package, you will be able to make use of all the features of QuantumPath® without the need to install the rest of the SDKs of the different manufacturers. All this is handled internally by QuantumPath®.
Step 6: Working with QuantumPath® PySDK
After these steps, the only thing left to do is to work with the created Jupyter Notebook. As it is already known, it follows a system of cells where lines of code can be executed individually.
To work with the QuantumPath® SDK, simply import the library, and you can make use of its functionalities by adding cells with the “+ Code” button, clicking on one of them, and pressing the button to the left of each cell to execute its code.

Figure 22. Using the SDK in Visual Studio Code
Start producing…
In this article, we have been able to see the configuration from scratch of two environments where you can use the QuantumPath® Python SDK. Thanks to the enormous versatility of Python, you can easily make use of QuantumPath® functions as long as you have access to the language and the ability to download the SDK. These are just two examples of places to create classical-quantum algorithms out of the many that exist.
It is important to note that QuantumPath® does not only work with Python. Languages such as C# or Java -to give just a few examples- are very common languages in the industry and make it possible to develop professional solutions with their corresponding manufacturer’s tools. And QuantumPath® supports them with pre-built SDKs. But if the reader uses any other language for which no preconfigured SDK is provided, he can always develop his own using the REST API documentation part of the platform. No limitation.
On qSOA’s QuantumPath® portal, both quick-start jupyter notebooks and up to 11 full tutorials on how to work with the PySDK are provided. We encourage the reader to access the portal and browse its contents.
https://qsoa.quantumpath.app:8443/
Also, if the reader wants to test the technology, it can be done for free with the Free Developer license, being able to run the experiments against the simulators provided by the backend, from multiple vendors.
https://core.quantumpath.app/OnlineRegistry/UserOnlineRegistry