root user execution fails
<p>When I run <code>python abc.py</code> it runs fine</p>

<p>But when I do sudo <code>python abc.py</code> then it shows some packages missing error. Of the several import errors, here's the one:</p>

<pre class="lang-none prettyprint-override"><code>ImportError: No module named numpy
</code></pre>

<p>Why?</p>

<p>What I think is that those packages are installed with normal user(ubuntu) permissions and not root permissions. If this is the case, how should I get over with this? Do I have to install all the packages again with root access?</p>

<p>Note: everything I discussed here is w.r.t ec2 linux ubuntu machine</p>

<p>The sudo environment may not contain your <code>PYTHONPATH</code></p>

<p><code>/etc/sudoers</code> contains Defaults <code>env_reset</code>.
Simply add Defaults <code>env_keep += "PYTHONPATH"</code> to <code>/etc/sudoers</code> and it will work just fine with <code>sudo</code>.</p>

python linux python-2.7