0 Votes

Introduction to Python

Last modified by Omid Abouali on 2026/08/26 10:23

Previous (None)     |     Back to Start     |     Next (Resize windows)

Introduction to Python

Python, a renowned programming language, finds its niche in the domains of scientific computing and simulations. What sets it apart is its clear syntax and approachable learning curve, making it a prime choice for newcomers.

In the Python landscape, packages are pivotal, offering specialized functionalities. Some prominent examples include:

  • Numpy: A numerical workhorse that handles complex number crunching.
  • Scipy: A scientific toolkit for intricate analysis and computations.
  • Matplotlib: The go-to tool for crafting insightful data visualizations.
  • Pandas: A versatile library for data manipulation and analysis.

To wield these tools, you enlist the help of package managers:

  • pip: The default choice for package installation, bringing in packages with ease.
  • Conda: A powerful alternative that streamlines package management.

Python, more than just a language, becomes your toolkit for innovation, accessible to all levels of programmers. Welcome to the IDA ICE Python community, where possibilities flourish through code.

The IDA ICE Python distribution (Suggested!)

  • One problem with Python: getting the correct version of all packages (especially for Windows users).
  • IDA ICE contains a standard Python distribution, therefore you don't need to install packages manually.
  • To run a program using the IDA ICE Python distribution, Open the command prompt terminal by searching cmd in the Windows search bar.
  • Change the directory to where the Python distribution is under the IDA ICE installation: 

>> cd "C:\\Program Files (x86)\\IDA ICE <YOUR IDA VERSION>\\bin\\python"

Note 1: Replace <YOUR IDA VERSION> with your IDA ICE version, e.g., 5.0 or 5.0 beta 28. 

  • Now you can run the main.py script by typing:

>> python.exe "C:\\<USER DIR>\\example\\Introduction\\main.py"

Note 2: Replace <USER DIR> with your user directory where the downloaded examples are saved to. 

  • You will see "Hello world!" printed in your terminal. Open main.py using any text editors, and you will see this (read carefully the Important:): 

Important 1: to run with IDA ICE Python distribution, the function in your script must be called from main() and use our given structure.

def main():

    print("Hello world!")

if __name__ == "__main__":
    main()

Important 2: IDA ICE python can only execute scripts with .py extension. For Windows users, it is likely that you don't know how to create a main script with .py extension. For instance, copy and paste the above lines to the Windows text editor. Saving the text will give you main.txt instead of main.py. You can view the extension as follows (then you can change .txt to .py):

view_extension.png

The Conda Python Distribution

Other than using IDA ICE Python distribution, you can use Conda Python Distribution. We will provide you with an environmental file, which will allow you to set up your environment quickly and gain more flexibility in installing other libraries you found on the internet. A detailed procedure for using Conda Python Distribution in Windows is provided below:

  • Step 1: Download and install Anaconda into your system.
  • Step 2: Open the Anaconda Prompt terminal by searching anaconda in the Windows search bar.

conda1.png

conda2.png

  • Step 3: Copy and Paste environment.yml to a text file of the same name. Change the extension to .yml (alternatively use environment.txt in the command line). Create an Anaconda environment by typing in the terminal:

>> conda env create -f environment.yml

  • Step 4: Activate the Anaconda environment named: Equa by typing in the terminal:

>> conda activate Equa

You will notice a change of environment from (base) to (Equa):

conda3.png

  • Step 5: Run the main.py by specifying the path to the downloaded examples as,

>> python "C:\\<USER DIR>\\example\\Introduction\\main.py"

IDA ICE Python or Conda Python Distribution?

  • IDA ICE Python distribution provides you with up-to-date libraries that are compatible with our released IDA ICE Version. Direct usage with no other installations needed.
  • Conda Python distribution provides users with more flexibility in terms of Python structure and function calls. However, third-party libraries may be incompatible with our IDA ICE version and you have to debug quite often.

Previous (None)     |     Back to Start     |     Next (Resize windows)