How to activate virtualenv in Cygwin
<p>complete beginner here. Trying to build a flask web app. Using Windows 8.</p>

<p>Having some problems activating my python virtualenv in Cygwin. I have been using git shell up till now with no problems.</p>

<p>I copied my folder ("app") into my cygwin home directory and it is set up like so:</p>

<pre><code>app - templates
    - static
    - flask - env - scripts - python
                  - ...
    - hello.py
    - ...
</code></pre>

<p>I change directory into the app folder, then when I type the command to activate my virtualenv:</p>

<pre><code>$ source flask/env/scripts/activate
</code></pre>

<p>The terminal shows:</p>

<pre><code>(env)
</code></pre>

<p>so I assume that it is working, until I double check which python:</p>

<pre><code>$ which python
</code></pre>

<p>and that returns my original global python install, not the virtual environment. I've checked the installed packages to double check which python environment I am using.</p>

<p>I use the same command in git shell and it activates the right virtualenv. Where am I going wrong / what do I need to change? Please let me know if you need any more information.</p>

<p>I created a new virtual environment using cygwin and when I activated the new env, it switched to that environment fine. Why won't it work for the folder which I copied in?</p>

<p>Thanks,</p>

<p>Sam</p>

<p>You should not move the virtualenv. The <code>activate</code> script inside the virtualenv uses absolute paths internally. If you move the directory, the paths will no longer work, and so <code>which python</code> finds the first valid binary on <code>PATH</code>, which is your global binary.</p>

<p>If you need to move the project to a different location, and the virtualenv together with it, then recreate the virtualenv, do not copy it.
The recommended practice is to have a <code>requirements.txt</code> file, and install packages using <code>pip install -r requirements.txt</code>.
That way, recreating a virtualenv is very easy: create an empty virtualenv, and run the <code>pip ...</code> command. There should be nothing else inside the virtualenv that needs moving, only what <code>pip</code> put there, or other python installer scripts, if you used any (and which you would need to re-run, in addition to <code>pip</code>).</p>

python shell cygwin virtualenv