Setup Virtualenv Python

Install Virtualenv

sudo pip install virtualenv

buat sebauh environment baru dengan directory python berada didalam venv

virtualenv venv

Aktifkan virtualenv

source venv/bin/activate

Pastikan virtualenv jalan dengan mengambil module yang sudah terinstall (pastikan kosong)

(venv) zufar@zufar:~/Documents/Technology/Programming/Python/webserver$ pip freeze > modules.txt
(venv) zufar@zufar:~/Documents/Technology/Programming/Python/webserver$ cat modules.txt 
(venv) zufar@zufar:~/Documents/Technology/Programming/Python/webserver$

Coba install sebuah module

(venv) zufar@zufar:~/Documents/Technology/Programming/Python/webserver$ pip install jinja2
Collecting jinja2
  Using cached https://files.pythonhosted.org/packages/7f/ff/ae64bacdfc95f27a016a7bed8e8686763ba4d277a78ca76f32659220a731/Jinja2-2.10-py2.py3-none-any.whl
Collecting MarkupSafe>=0.23 (from jinja2)
Installing collected packages: MarkupSafe, jinja2
Successfully installed MarkupSafe-1.0 jinja2-2.10
(venv) zufar@zufar:~/Documents/Technology/Programming/Python/webserver$ pip freeze > modules.txt
(venv) zufar@zufar:~/Documents/Technology/Programming/Python/webserver$ cat modules.txt 
Jinja2==2.10
MarkupSafe==1.0

Log :

zufar@zufar:~/Documents/Technology/Programming/Python/webserver$ ls
zufar@zufar:~/Documents/Technology/Programming/Python/webserver$ virtualenv venv
Using base prefix '/usr'
New python executable in /home/zufar/Documents/Technology/Programming/Python/webserver/venv/bin/python3
Also creating executable in /home/zufar/Documents/Technology/Programming/Python/webserver/venv/bin/python
Installing setuptools, pip, wheel...done.
zufar@zufar:~/Documents/Technology/Programming/Python/webserver$ source venv/bin/activate
(venv) zufar@zufar:~/Documents/Technology/Programming/Python/webserver$

 

Comments are closed.