title: Importing installed package from script with the same name raises "AttributeError: module has no attribute" or "ImportError: cannot import name"
body: <p>I have a script named <code>requests.py</code> that imports the requests package.  The script either can't access attributes from the package, or can't import them.  Why isn't this working and how do I fix it?</p>
  
  <p>The following code raises an <code>AttributeError</code>.</p>
  
  <pre><code>import requests
  
  res = requests.get('http://www.google.ca')
  print(res)
  </code></pre>
  
  <pre class="lang-none prettyprint-override"><code>Traceback (most recent call last):
    File "/Users/me/dev/rough/requests.py", line 1, in &lt;module&gt;
      import requests
    File "/Users/me/dev/rough/requests.py", line 3, in &lt;module&gt;
      requests.get('http://www.google.ca')
  AttributeError: module 'requests' has no attribute 'get'
  </code></pre>
  
  <p>The following code raises an <code>ImportError</code>.</p>
  
  <pre><code>from requests import get
  
  res = get('http://www.google.ca')
  print(res)
  </code></pre>
  
  <pre class="lang-none prettyprint-override"><code>Traceback (most recent call last):
    File "requests.py", line 1, in &lt;module&gt;
      from requests import get
    File "/Users/me/dev/rough/requests.py", line 1, in &lt;module&gt;
      from requests import get
  ImportError: cannot import name 'get'
  </code></pre>
  
  <p>Or code that imports from a module inside the <code>requests</code> package:</p>
  
  <pre><code>from requests.auth import AuthBase
  </code></pre>
  
  <pre class="lang-none prettyprint-override"><code>Traceback (most recent call last):
    File "requests.py", line 1, in &lt;module&gt;
      from requests.auth import AuthBase
    File "/Users/me/dev/rough/requests.py", line 1, in &lt;module&gt;
      from requests.auth import AuthBase
  ImportError: No module named 'requests.auth'; 'requests' is not a package
  </code></pre>