I referred to these questions before asking this:
https://stackoverflow.com/a/1383009/5157633
https://stackoverflow.com/a/4987569/5157633
Currently I have created a virtual environment as follows:
export PYTHONPATH=
virtualenv --no-site-packages env4
source env4/bin/activate
and then installed the following packages:
(env4) shuba@shuba-XPS-13-9360: pip install numpy==1.13.1
(The system numpy has v 1.15)
Collecting numpy==1.13.1
Using cached https://files.pythonhosted.org/packages/5f/d2/9fa0201944933afd6d059f1e32aa6bdb203b23ab62fc823d3adf36295b9a/numpy-1.13.1-cp27-cp27mu-manylinux1_x86_64.whl
Installing collected packages: numpy
Successfully installed numpy-1.13.1
Likewise for pandas. However, when I try to install other packages like the following:
(env4) shuba@shuba-XPS-13-9360: pip install python-dateutil==2.6.1
Collecting python-dateutil==2.6.1
Downloading https://files.pythonhosted.org/packages/4b/0d/7ed381ab4fe80b8ebf34411d14f253e1cf3e56e2820ffa1d8844b23859a2/python_dateutil-2.6.1-py2.py3-none-any.whl (194kB)
100% |████████████████████████████████| 194kB 4.9MB/s
Requirement already satisfied: six>=1.5 in ./env4/lib/python2.7/site-packages (from python-dateutil==2.6.1) (1.11.0)
Installing collected packages: python-dateutil
Found existing installation: python-dateutil 2.7.3
Uninstalling python-dateutil-2.7.3:
Successfully uninstalled python-dateutil-2.7.3
Successfully installed python-dateutil-2.6.1
indicating that it has replaced the system-wise python-dateutil. I also checked it by running pip freeze from outside the virtual env.
What I find confusing is dateutil exists inside dist-packages folder of python2.7 and yet it got updated, while the other answers mentioned that the ones in the original installation get included by virtualenv pip.
The same thing happened for pytz:
(env4) shuba@shuba-XPS-13-9360: pip install pytz==2017.2
Collecting pytz==2017.2
Downloading https://files.pythonhosted.org/packages/55/62/e7cd0e15b76062d298413f14bb4ec3cd8568a22d274427f9c3c7286969f4/pytz-2017.2-py2.py3-none-any.whl (484kB)
100% |████████████████████████████████| 491kB 4.7MB/s
Installing collected packages: pytz
Found existing installation: pytz 2018.5
Uninstalling pytz-2018.5:
Successfully uninstalled pytz-2018.5
Successfully installed pytz-2017.2
Is there a way to fix the above problem I encountered?