title: How to include a text file in a python installed package?
body: <p>I have created a python package that looks like this:</p>
  
  <pre><code>/command
      /command
          module.py
          __main__.py
      README.md
      setup.py
      file.txt
  </code></pre>
  
  <p>To install i run:</p>
  
  <pre><code>sudo python setup.py install
  </code></pre>
  
  <p>Now when i call</p>
  
  <pre><code>$ command
  </code></pre>
  
  <p>it shows this error:</p>
  
  <pre><code>FileNotFoundError: [Errno 2] No such file or directory: '../file.txt'
  </code></pre>
  
  <p>There are approximately the contents of modules <strong>setup.py</strong>, <strong>__main__.py</strong> and <strong>module.py</strong></p>
  
  <p><strong>setup.py</strong></p>
  
  <pre><code>import setuptools
  
  setuptools.setup(
      name='command',
      ...
      entry_points={
          'console_scripts': [
              'command = command.__main__:main'
          ]
      }
  )
  </code></pre>
  
  <p><strong>__main__.py</strong></p>
  
  <pre><code>from . import module
  
  def main():
      module.run('arg')
  </code></pre>
  
  <p><strong>module.py</strong></p>
  
  <pre><code>import shutil
  
  # copy file.txt from command project into the directory where it is running
  def run(arg):
      shutil.copyfile('../file.txt', './file.txt')
  </code></pre>
  
  <p>After intalling this package via:</p>
  
  <pre><code>sudo python setup.py install
  </code></pre>
  
  <p>And calling the program at the command line</p>
  
  <pre><code>$ command
  </code></pre>
  
  <p>I get the error below</p>
  
  <pre><code>FileNotFoundError: [Errno 2] No such file or directory: '../file.txt'
  </code></pre>
  
  <p>How can I see and use a file that belongs to the installed package but I to use it in an environment where I am running that program?</p>
  
  <p><strong>Edit:</strong></p>
  
  <p><a href="https://github.com/mctrjalloh/project_initializer" rel="noreferrer">This a simplification of the problem you can download and test:</a></p>
  
  <p><a href="https://github.com/mctrjalloh/project_initializer" rel="noreferrer">https://github.com/mctrjalloh/project_initializer</a></p>