title: Use Python 2.7.10 in Virtual Environment
body: <p>I have already wasted several hours on this issue and am trapped. Could anyone help me out? Thanks.</p>
  
  <p>I have both Python 2.7.10 and Python 3.4 installed in my Macbook through Homebrew. At the same time, the macbook has its default 2.7.6 which is to be avoided as it does not bundle with pip.</p>
  
  <p>Python 3.4 is symbolick</p>
  
  <pre><code>/usr/local/bin/python3
  ../../../Library/Frameworks/Python.framework/Versions/3.4/bin/python3
  </code></pre>
  
  <p>Python 2.7.10 is </p>
  
  <pre><code>/usr/local/bin/python2
  /usr/local/Cellar/python/2.7.10_2/bin/python
  </code></pre>
  
  <p>Now, I have python 2.7 web app to run. Naturally, I need to create a virtual environment by python 2.7.10. </p>
  
  <p><strong>Either</strong></p>
  
  <p>1) create a python 2.7 virtual environment</p>
  
  <p>Steps I researched are:</p>
  
  <pre><code>a. pip install virtualenv
  
  b. virtualenv -p /usr/local/bin/python2 &lt;path/to/new/virtualenv/&gt;
  </code></pre>
  
  <p>However, in step a, there is error:</p>
  
  <pre><code>~ $/usr/local/Cellar/python/2.7.10_2/bin/pip install virtualenv
  Traceback (most recent call last):
    File "/usr/local/Cellar/python/2.7.10_2/bin/pip", line 5, in &lt;module&gt;
      from pkg_resources import load_entry_point
  ImportError: No module named pkg_resources
  </code></pre>
  
  <p><strong>Or</strong></p>
  
  <p>2) Use python 2.7 in virtual environment created by Python 3.4. Does anyone know how to choose python 2.7 inside the virtual environment created by Python 3.4?</p>
  
  <p>I use this link to create virtual environment in Python 3.4</p>
  
  <p><a href="https://docs.python.org/3/library/venv.html" rel="nofollow">https://docs.python.org/3/library/venv.html</a></p>
  
  <p><strong>UPDATE:</strong>
  Thanks for both answers. I resolved the Question 1).</p>
  
  <p>Essentially, you need to add --user when installing the setuptools and virtualenv. For example,</p>
  
  <pre><code>~ $pip install virtualenv==1.5.2 --user
  </code></pre>
  
  <p>Here is my test results:</p>
  
  <pre><code>     ~ $virtualenv -p /usr/local/bin/python2 test_python2/
      Traceback (most recent call last):
        File "/usr/local/bin/virtualenv", line 5, in &lt;module&gt;
          from pkg_resources import load_entry_point
        File "build/bdist.macosx-10.10-intel/egg/pkg_resources/__init__.py", line 3084, in &lt;module&gt;
        File "build/bdist.macosx-10.10-intel/egg/pkg_resources/__init__.py", line 3070, in _call_aside
        File "build/bdist.macosx-10.10-intel/egg/pkg_resources/__init__.py", line 3097, in _initialize_master_working_set
        File "build/bdist.macosx-10.10-intel/egg/pkg_resources/__init__.py", line 653, in _build_master
        File "build/bdist.macosx-10.10-intel/egg/pkg_resources/__init__.py", line 666, in _build_from_requirements
        File "build/bdist.macosx-10.10-intel/egg/pkg_resources/__init__.py", line 839, in resolve
      pkg_resources.DistributionNotFound: The 'virtualenv==1.5.2' distribution was not found and is required by the application
      ~ $
      ~ $
  
      ~ $virtualenv -p /usr/local/bin/python2 test_python2/
      Running virtualenv with interpreter /usr/local/bin/python2
      New python executable in test_python2/bin/python2.7
      Also creating executable in test_python2/bin/python
      Installing setuptools..................done.
      ~ $ls test_python2/
      bin include lib
      ~ $
      ~ $cd test_python2/
      ~/test_python2 $source bin/activate
      (test_python2)~/test_python2 $
      (test_python2)~/test_python2 $python
      Python 2.7.10 (default, Jul 13 2015, 12:05:58)
      [GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)] on darwin
      Type "help", "copyright", "credits" or "license" for more information.
      &gt;&gt;&gt;
      (test_python2)~/test_python2 $
      (test_python2)~/test_python2 $
  </code></pre>