Python import error: 'Cannot import name'
<p>Im having trouble importing a class on a python module.</p>

<p>Here are my directory structure:</p>

<pre><code>_wikiSpider
  +scrapy.cfg
  _wikiSpider
    +__init__.py
    +items.py
    +items.pyc
    +settings.py
    +settings.pyc
    +pipelines.py
    _spiders
     +__init__.py
     +__init__.pyc
     +articleSpider.py
     +articleSpider.pyc
     +items.py
</code></pre>

<p>Code breaks at this line:</p>

<pre><code>from wikiSpider.items import Article
</code></pre>

<p>Im not sure why, since class Article is defined at items.py (deepest folder)</p>

<p>Can someone give me an explanation?</p>

<p>You have an items.py in both your root and _spiders folder.  To reference a file in a subfolder you need the folder name and the file.</p>

<p>from _spiders.items import Article </p>

<p>assuming the file that imports this code is in your root directory.  Python uses a you are here, to current file location, for it's directory hierarchy.</p>

python import scrapy