0

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?

thegreatcoder
  • 2,173
  • 3
  • 19
  • 28
  • The 1st command `pip install numpy==1.13.1` is being run in the *env4* virtual env. But what about 2 other `pip install` commands? They seems to be running outside of any venv. – phd Sep 07 '18 at 13:38
  • No. I had forgottent to paste the text there. They run in the virtual env. – thegreatcoder Sep 07 '18 at 13:40
  • `echo $PYTHONPATH` in the env4? `python -c "import sys; print sys.path"`? – phd Sep 07 '18 at 13:45
  • `echo $PYTHONPATH` gives a blank line `python -c print sys.path` `['','/opt/custom_python_venv/env4/lib/python2.7', '/opt/custom_python_venv/env4/lib/python2.7/plat-x86_64-linux-gnu', '/opt/custom_python_venv/env4/lib/python2.7/lib-tk', '/opt/custom_python_venv/env4/lib/python2.7/lib-old', '/opt/custom_python_venv/env4/lib/python2.7/lib-dynload', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/opt/custom_python_venv/martingale4/local/lib/python2.7/site-packages', '/opt/custom_python_venv/martingale4/lib/python2.7/site-packages']` – thegreatcoder Sep 07 '18 at 13:53
  • 1
    I see two virtual envs at once: `env4` and `martingale4`. `pip install` seems to replace packages in `martingale4`, not in python. – phd Sep 07 '18 at 13:56
  • That was a mistake from my side. I had replaced martingale4 with env4 in the text for the sake of posting on this site. Apologies. It is installing in the right location. – thegreatcoder Sep 07 '18 at 14:24
  • I still face the same problem. Can someone help? – thegreatcoder Sep 09 '18 at 19:55

0 Answers0