Monday, December 31, 2018

Python - Using virtualenv

Step1: Create a virtual environment:

/opt3$ virtualenv runs02
Running virtualenv with interpreter /usr/bin/python2
New python executable in /opt3/runs02/bin/python2
Also creating executable in /opt3/runs02/bin/python
Installing setuptools, pkg_resources, pip, wheel...done.
/opt3$

Step 2: Activate the environment:

$ cd runs02
/opt3/runs02$ ls -l
total 0
drwxr-xr-x 2 mhc mhc 320 Dec 31 12:51 bin
drwxr-xr-x 2 mhc mhc  60 Dec 31 12:51 include
drwxr-xr-x 3 mhc mhc  60 Dec 31 12:51 lib
drwxr-xr-x 2 mhc mhc 100 Dec 31 12:51 local
drwxr-xr-x 3 mhc mhc  60 Dec 31 12:51 share
/opt3/runs02$ which source
opt3/runs02$ $ source bin/activate
(runs02) /opt3/runs02$

Step 3: Now install the needed packages using pip.

Installing pandas:

(runs02) /opt3/runs02$ pip install pandas
Collecting pandas
  Downloading https://files.pythonhosted.org/packages/b7/e3/f52d484244105fa3d558ce8217a5190cd3d40536076bef66d92d01566325/pandas-0.23.4-cp27-cp27mu-manylinux1_x86_64.whl (8.9MB)
    100% |████████████████████████████████| 8.9MB 2.2MB/s 
Collecting pytz>=2011k (from pandas)
  Downloading https://files.pythonhosted.org/packages/f8/0e/2365ddc010afb3d79147f1dd544e5ee24bf4ece58ab99b16fbb465ce6dc0/pytz-2018.7-py2.py3-none-any.whl (506kB)
    100% |████████████████████████████████| 512kB 10.7MB/s 
Collecting numpy>=1.9.0 (from pandas)
  Downloading https://files.pythonhosted.org/packages/de/37/fe7db552f4507f379d81dcb78e58e05030a8941757b1f664517d581b5553/numpy-1.15.4-cp27-cp27mu-manylinux1_x86_64.whl (13.8MB)
    100% |████████████████████████████████| 13.8MB 1.4MB/s 
Requirement already satisfied: python-dateutil>=2.5.0 in ./lib/python2.7/site-packages (from pandas) (2.7.5)
Requirement already satisfied: six>=1.5 in ./lib/python2.7/site-packages (from python-dateutil>=2.5.0->pandas) (1.12.0)
Installing collected packages: pytz, numpy, pandas
Successfully installed numpy-1.15.4 pandas-0.23.4 pytz-2018.7
(runs02) /opt3/runs02$



Reference:

No comments:

Post a Comment