Where should I locate my Python file if I want to use virtualenv?
<p>I have a virtual environment and I do not know where should I save my Python file ? it only works when I run it in <code>/home/jojo/Enviroment/venv1</code> can I save it in other place ? Especially when I want to use PyCharm thank you </p>

<p>virtualenv and your code base <strong>can</strong> very well be in different locations. I prefer things this way. Here are sample commands that I use.  </p>

<p><strong>Step 1</strong>: Activate the virtualenv.</p>

<pre><code>[mayank@demo /dev]$ source /usr/local/pyenv3.4/bin/activate
(pyenv3.4)[mayank@demo dev]$ 
</code></pre>

<p>Notice the prefix "(pyenv3.4)" that indicates that virtualenv is now activated.</p>

<p><strong>Step 2</strong>: Ensure that python executable in virtualenv is indeed pointed by "python"</p>

<pre><code>(pyenv3.4)[mayank@demo dev]$ which python 
/usr/local/pyenv3.4/bin/python
</code></pre>

<p>Notice that python is indeed pointing to the one in virtualenv directory.</p>

<p><strong>Step 3</strong>: Create a file elsewhere and execute it</p>

<pre><code>echo "import sys; print(sys.executable)" &gt; /tmp/print_python_exe.py
python /tmp/print_python_exe.py
</code></pre>

<p>Edit: As suggested by Paul, one might choose to keep the virtualenv directory inside the app directory. This style of structuring projects is also suggested here: <a href="http://docs.python-guide.org/en/latest/dev/virtualenvs/#basic-usage" rel="nofollow">http://docs.python-guide.org/en/latest/dev/virtualenvs/#basic-usage</a></p>

python pycharm virtualenv