MODUL PERKULIAHAN
W142100009–
Pemrograman
Komputer 2
Fungsi Library untuk Komputasi
Saintifik (Scientific Computing)
Abstrak Sub-CPMK
02
Freddy Artadima Silaban,S.Kom,MT
Teknik Teknik Elektro
Bagian Isi
Pembahasan
Bekerja pada modus baris perintah sangat baik untuk membuat program dan untuk
mencoba - coba algoritma, karena Anda dapat langsung menjalankan perintah
tersebut dan melihat hasilnya. Tetapi pada saat Anda ingin membuat program atau
aplikasi yang real, Anda seharusnya menyimpan ke dalam bentuk script, jadi dapat Anda
jalankan dan dimodifikasi untuk pengembangan program selanjutnya. Contoh aplikasi
Python yang dapat kita temui adalah konfigurator - konfigurator dalam suatu
distribusi, seperti Xconfigurator dan Installer Distribusi RedHat (Anaconda).
7. Select the file you downloaded – and click twice. You will see the following screen
and then select Next and I agree on the following screen. See below and follow
selections.
9. Select: Add Anaconda to my PATH environment variable. Now wait for the install.
This will take quite a long time…
18. In the Anaconda display select the New button and Python 3
In the In cell you type simple commands one line at a time or an entire function
(we’ll get to that later).
Type 1+2 and then select either the run symbol Run or Control-Enter
You will now have an output cell that will display: 3. You have to ‘run’ each cell to
recognize your input or to print an output.
A Python example:
Try this simple Python example:
In the first cell type: a=1 then select Run
In the next cell type b=1 then select Run
In the third cell type c=a+b then select Run
In the fourth cell type print(c) then select Run
PyPI vs Conda
PyPI
• Official 3rd party Python Repository
• Instalasi menggunakan pip
– untuk install >> pip install <nama_package>
– untuk install versi tertentu >> pip install <nama_package>==<versi>
Conda
• open-source package management system
• Instalasi menggunakan conda
– untuk install >> conda install <nama_package>
– untuk install versi tertentu >> conda install <nama_package>==<versi>
Informasi Environment
• Untuk mengecek ada package apa saja di dalam environment
conda list --name <nama_env>
• Untuk mengecek sudah ada environment apa saja
conda env list
2. conda
membutuhkan file yang isinya informasi environment
secara konvensi nama file nya adalah environment.yml
instalasi semua package dan sekaligus membuat environment
command >> conda env create -f file_environment_nya
Cheat sheet
pip install <nama_package>
pip install <nama_package>==<versi>
pip install -r requirements.txt
conda create --name <nama_env> <nama_package> conda install --name <nama_env>
<nama_package>==<versi>
conda list --name <nama_env>
Conda: https://docs.conda.io/projects/conda/en/latest/user-guide/getting-started.html