<p>On Mar 19, 2012 4:48 AM, "Nick Coghlan" <<a href="mailto:ncoghlan@gmail.com">ncoghlan@gmail.com</a>> wrote:<br>
><br>
> For the record, I just thought of an easy workaround for the "erroneous successful import" case: drop an __init__.py file containing "raise ImportError" into the offending data directory.</p>
<p>It only works if you don't mind shadowing a later installation of the same-named package, further along on sys.path.</p>
<p>More to the point, it doesn'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:"import foo" to "try:from foo import something"</p>
<p>(Unfortunately, even that fix isn't purely correct, since if there's a foo/something subdirectory, you still get a false positive. It just further reduces the odds of a collision.)</p>