Tuesday, January 29, 2019

Python - Using virtualenv - python3


Step 1: Create a virtual environment for python3:

/opt3$ virtualenv -p python3 python3runs01
Already using interpreter /usr/bin/python3
Using base prefix '/usr'
New python executable in /opt3/python3runs01/bin/python3
Also creating executable in /opt3/python3runs01/bin/python
Installing setuptools, pkg_resources, pip, wheel...done.
/opt3$ 

Step 2: Change directory to the virtual environment folder:

/opt3$ cd python3runs01

Step 3: Activate the virtual environment:

/opt3/python3runs01$ source bin/activate
(python3runs01) /opt3/python3runs01$ 

Notice that, after you activate, a prompt is added. 
(python3runs01) /opt3/python3runs01$ ls -l
total 0
drwxr-xr-x 2 ubuntu ubuntu 320 Jan 29 11:50 bin
drwxr-xr-x 2 ubuntu ubuntu  60 Jan 29 11:50 include
drwxr-xr-x 3 ubuntu ubuntu  60 Jan 29 11:50 lib
drwxr-xr-x 3 ubuntu ubuntu  60 Jan 29 11:50 share
(python3runs01) /opt3/python3runs01$


Step 4: Deactivate from virtual environment:

(python3runs01) /opt3/python3runs01$ deactivate
/opt3/python3runs01$


References:

No comments:

Post a Comment