Are you activating the virtual environment correctly? After creating the virtualenv you should issue the command
source /Users/karim/Documents/venv2.7/bin/activate
to change your environment so the python command refers to the interpreter in the virtualenv. Remember the virtualenv has nothing to do with your current working directory ...
Is it possible that the virtualenv you are using is associated with the wrong Python binary? I have a lot of Pythons on my system, including Python3.7 and Python 2.7 in /usr/local/bin :
fathead:~ sholden$ ls -l /usr/local/bin/python*
lrwxr-xr-x 1 sholden staff 38 6 Dec 12:26 /usr/local/bin/python@ -> ../Cellar/python@2/2.7.15_1/bin/python
lrwxr-xr-x 1 sholden staff 38 6 Dec 12:34 /usr/local/bin/python-build@ -> ../Cellar/pyenv/1.2.8/bin/python-build
lrwxr-xr-x 1 sholden staff 45 6 Dec 12:26 /usr/local/bin/python-config@ -> ../Cellar/python@2/2.7.15_1/bin/python-config
lrwxr-xr-x 1 sholden staff 39 6 Dec 12:26 /usr/local/bin/python2@ -> ../Cellar/python@2/2.7.15_1/bin/python2
lrwxr-xr-x 1 sholden staff 46 6 Dec 12:26 /usr/local/bin/python2-config@ -> ../Cellar/python@2/2.7.15_1/bin/python2-config
lrwxr-xr-x 1 sholden staff 41 6 Dec 12:26 /usr/local/bin/python2.7@ -> ../Cellar/python@2/2.7.15_1/bin/python2.7
lrwxr-xr-x 1 sholden staff 48 6 Dec 12:26 /usr/local/bin/python2.7-config@ -> ../Cellar/python@2/2.7.15_1/bin/python2.7-config
lrwxr-xr-x 1 sholden staff 34 6 Dec 12:22 /usr/local/bin/python3@ -> ../Cellar/python/3.7.1/bin/python3
lrwxr-xr-x 1 sholden staff 41 6 Dec 12:22 /usr/local/bin/python3-config@ -> ../Cellar/python/3.7.1/bin/python3-config
lrwxr-xr-x 1 sholden staff 36 6 Dec 12:22 /usr/local/bin/python3.7@ -> ../Cellar/python/3.7.1/bin/python3.7
lrwxr-xr-x 1 sholden staff 43 6 Dec 12:22 /usr/local/bin/python3.7-config@ -> ../Cellar/python/3.7.1/bin/python3.7-config
lrwxr-xr-x 1 sholden staff 37 6 Dec 12:22 /usr/local/bin/python3.7m@ -> ../Cellar/python/3.7.1/bin/python3.7m
lrwxr-xr-x 1 sholden staff 44 6 Dec 12:22 /usr/local/bin/python3.7m-config@ -> ../Cellar/python/3.7.1/bin/python3.7m-config
lrwxr-xr-x 1 sholden staff 39 6 Dec 12:26 /usr/local/bin/pythonw@ -> ../Cellar/python@2/2.7.15_1/bin/pythonw
lrwxr-xr-x 1 sholden staff 40 6 Dec 12:26 /usr/local/bin/pythonw2@ -> ../Cellar/python@2/2.7.15_1/bin/pythonw2
lrwxr-xr-x 1 sholden staff 42 6 Dec 12:26 /usr/local/bin/pythonw2.7@ -> ../Cellar/python@2/2.7.15_1/bin/pythonw2.7
-rwxr-xr-x@ 1 sholden staff 230 25 Sep 2017 /usr/local/bin/pythonz*
The which (also type on MacOS) which tell you which executable a command is associated. I verified I was getting the right python3.7 with
fathead:~ sholden$ which python3.7
/usr/local/bin/python3.7
To ensure I use the correct Python's virtualenv I use the Python binary to execute it:
fathead:~ sholden$ python3.7 -m virtualenv -p /usr/local/bin/python2.7 venv2.7
Running virtualenv with interpreter /usr/local/bin/python2.7
New python executable in /Users/sholden/venv2.7/bin/python2.7
Also creating executable in /Users/sholden/venv2.7/bin/python
Installing setuptools, pip, wheel...
done.
It may turn out that your Python 3.7 doesn't have virtualenv installed. If so, install it with
fathead:~ sholden$ python3.7 -m pip install virtualenv
Looking in indexes: https://pypi.org/simple, https://pypi.python.org/simple
Collecting virtualenv
Downloading https://files.pythonhosted.org/packages/7e/1b/6c00d57127608793e16e8b7f813e64d58a1938505c42fe190d1386ab41e1/virtualenv-16.4.0-py2.py3-none-any.whl (2.0MB)
100% |████████████████████████████████| 2.0MB 3.4MB/s
Installing collected packages: virtualenv
Successfully installed virtualenv-16.4.0
After creating the virtualenv you should be able to activate it as described.