title: Troubleshooting 'distribution not found' pkg_resources with Poetry
body: <p>I am building a cli application, in which I am using <a href="https://python-poetry.org/" rel="nofollow noreferrer">poetry</a> and <code>pyproject.toml</code> to define my application's version:</p>
  <pre><code>[tool.poetry]
  name = &quot;fili&quot;
  version = &quot;0.1.0&quot;
  description = &quot;My super awesome program.&quot;
  authors = [&quot;Jacob Pavlock &lt;jtpavlock@gmail.com&gt;&quot;]
  license = &quot;MIT&quot;
  </code></pre>
  <p>Now, I'd like to programatically access this version number in the CLI for my application, so I added the following code to <code>cli.py</code></p>
  <pre class="lang-py prettyprint-override"><code>import argparse
  import pkg_resources
  
  
  def main():
      &quot;&quot;&quot;Run our cli.&quot;&quot;&quot;
      VERSION = pkg_resources.get_distribution(&quot;fili&quot;).version
  
      fili_parser = argparse.ArgumentParser(description=&quot;Run fili.&quot;)
      fili_parser.add_argument(
          &quot;--version&quot;, action=&quot;version&quot;, version=&quot;%(prog)s {0}&quot;.format(VERSION)
      )
  
  
  if __name__ == &quot;__main__&quot;:
      main()
  </code></pre>
  <p>However, when run, I get the following error:</p>
  <pre><code>$ ./fili/cli.py 
  Traceback (most recent call last):
    File &quot;./fili/cli.py&quot;, line 22, in &lt;module&gt;
      main()
    File &quot;./fili/cli.py&quot;, line 11, in main
      VERSION = pkg_resources.get_distribution(&quot;fili&quot;).version
    File &quot;/home/jacob/.cache/pypoetry/virtualenvs/fili-yAte7WxV-py3.8/lib/python3.8/site-packages/pkg_resources/__init__.py&quot;, line 481, in get_distribution
      dist = get_provider(dist)
    File &quot;/home/jacob/.cache/pypoetry/virtualenvs/fili-yAte7WxV-py3.8/lib/python3.8/site-packages/pkg_resources/__init__.py&quot;, line 357, in get_provider
      return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]
    File &quot;/home/jacob/.cache/pypoetry/virtualenvs/fili-yAte7WxV-py3.8/lib/python3.8/site-packages/pkg_resources/__init__.py&quot;, line 900, in require
      needed = self.resolve(parse_requirements(requirements))
    File &quot;/home/jacob/.cache/pypoetry/virtualenvs/fili-yAte7WxV-py3.8/lib/python3.8/site-packages/pkg_resources/__init__.py&quot;, line 786, in resolve
      raise DistributionNotFound(req, requirers)
  pkg_resources.DistributionNotFound: The 'fili' distribution was not found and is required by the application
  </code></pre>
  <p>For reference, my project directory structure</p>
  <pre><code>$ tree
  .
  ├── fili
  │   ├── cli.py
  │   ├── __init__.py
  │   └── __pycache__
  │       ├── cli.cpython-38.pyc
  │       └── __init__.cpython-38.pyc
  ├── fili.egg-info
  │   ├── dependency_links.txt
  │   ├── PKG-INFO
  │   ├── SOURCES.txt
  │   └── top_level.txt
  ├── LICENSE
  ├── poetry.lock
  ├── pyproject.toml
  └── README.md
  </code></pre>
  <p>I have installed my package with <code>poetry install</code>, but what else am I missing?</p>