Package version difference between pip and OS?
<p>I have Debian OS and python version 2.7 installed on it. But I have a strange issue about package <code>six</code>. I want to use 1.10 version. </p>

<p>I have installed six 1.10 via pip:</p>

<pre><code>$ pip list
...
six (1.10.0)
</code></pre>

<p>But when I run the following script</p>

<pre><code>python -c "import six; print(six.__version__)"
</code></pre>

<p>it says <code>1.8.0</code></p>

<p>The reason is that veriosn installed in OS is different:</p>

<pre><code>$ sudo apt-cache policy python-six
python-six:
Installed: 1.8.0-1
Candidate: 1.8.0-1
Version table:
    1.9.0-3~bpo8+1 0
      100 http://172.24.70.103:9999/jessie-backports/ jessie-backports/main amd64 Packages
*** 1.8.0-1 0
    500 ftp://172.24.70.103/mirror/jessie-debian/ jessie/main amd64 Packages
    500 http://172.24.70.103:9999/jessie-debian/ jessie/main amd64 Packages
    100 /var/lib/dpkg/status
</code></pre>

<p><strong>How to force python to use package installed via pip?</strong></p>

<p>You can use <code>virtualenv</code> for this.</p>

<pre><code>pip install virtualenv

cd project_folder
virtualenv venv
</code></pre>

<p><code>virtualenv venv</code> will create a folder in the current directory which will contain the Python executable files, and a copy of the pip library which you can use to install other packages. The name of the virtual environment (in this case, it was venv) can be anything; omitting the name will place the files in the current directory instead.</p>

<p>Set the wished python interpreter    </p>

<pre><code>virtualenv -p /usr/bin/python2.7 venv
</code></pre>

<p>Activate the environment</p>

<pre><code>source venv/bin/activate
</code></pre>

<p>From now on, any package that you install using pip will be placed in the <code>venv</code> folder, isolated from the <strong>global</strong> Python installation.</p>

<pre><code>pip install six
</code></pre>

<p>Now you run code. When you have finished simpliy deactivate <code>venv</code></p>

<pre><code>deactivate
</code></pre>

<p>See also <a href="http://docs.python-guide.org/en/latest/dev/virtualenvs/" rel="nofollow">the original resources</a>.</p>

python pip six