Sabtu, 26 Desember 2020

Set Up Sublime Text 3 to use Python 3 (with venv virtual environment) on Ubuntu 20.04

A. Set up virtual environment

1. I assume that you already have python on your computer (linux)

2. Install venv:

sudo apt install -y python3-venv

3. Create virtual environment inside your project directory (example for me: inside data-science folder ):

python3 -m venv venv_01

4. Activate virtual environment:

source venv_01/bin/activate

5. Deactivate virtual environment:

deactivate


B. Set up Sublime:

1. Open Sublime

2. Add new build system on your Sublime:

Tools -> Build System -> New Build System

3. Edit as follow:

{

    "cmd": ["/home/<username>/Desktop/data_science/venv_01/bin/python", "$file"],

    "file_regex": "^[ ]File \"(...?)\", line ([0-9]*)",

    "selector": "source.activate"

}

Replace <username> with your username.

/home/<username>/Desktop/data_science/venv_01 --> this is my virtual environment path (change with your path).

4. Save and give the name (example: python3_venv_01)


C. Test your set up:

1. Try to create simple python code in sublime. For example:

import sys

print(sys.version)

2. Let save as tes.py and save inside your project directory (which is the same folder with your virtual environment).

3. Set Build System 

Tools -> Build System -> python3_venv_01

4. To test if the app is working, press CTRL + B


References:

https://medium.com/@hariyanto.tan95/set-up-sublime-text-3-to-use-python-3-c845b742c720

https://towardsdatascience.com/python-virtual-environments-made-easy-fe0c603fe601

https://www.digitalocean.com/community/tutorials/how-to-install-python-3-and-set-up-a-programming-environment-on-an-ubuntu-20-04-server

Tidak ada komentar:

Posting Komentar

Selamat berinovasi :D Salam berbagi..

Cara mengetahui ip address raspberry atau perangkat lain yg terhubung pada wifi yg sama

1. Install nmap [jika belum ada]: sudo apt install nmap 2. Cek ip address komputer (yg akses ke wifi yang sama): ip addr misal hasilnya 192....