<p>On Mar 19, 2012 4:48 AM, &quot;Nick Coghlan&quot; &lt;<a href="mailto:ncoghlan@gmail.com">ncoghlan@gmail.com</a>&gt; wrote:<br>
&gt;<br>
&gt; For the record, I just thought of an easy workaround for the &quot;erroneous successful import&quot; case: drop an __init__.py file containing &quot;raise ImportError&quot; into the offending data directory.</p>
<p>It only works if you don&#39;t mind shadowing a later installation of the same-named package, further along on sys.path.</p>
<p>More to the point, it doesn&#39;t solve the real problem, which is noticing in the first place that this is happening.  The right way to fix it is to change your try:&quot;import foo&quot; to &quot;try:from foo import something&quot;</p>

<p>(Unfortunately, even that fix isn&#39;t purely correct, since if there&#39;s a foo/something subdirectory, you still get a false positive.  It just further reduces the odds of a collision.)</p>