3

This is the first time I'm creating a python package. I follow all the instructions in this text, which was very well written and I was able to replicate every step without any issue.

Thus, I created a local directory with the following structure:

mypackage/
    mypackage/
        __init__.py
        mypackage.py
    LICENSE.txt
    README.md
    setup.cfg
    setup.py

Next, I follow these steps:

  1. Push the directory to github
  2. Create a new release
  3. Update setup.py file
  4. run python setup.py sdist
  5. run twine upload dist/*

And proceed to install my package using pip. It works finely

However, when I tried to import it I got the following error:

FileNotFoundError: [Errno 2] File counties_1872_1991.csv does not exist: 'counties_1872_1991.csv'

Then I search for a while and found this two questions (here and here). Folowing the instructions in the answers to each question, I did:

  1. Create a MANIFEST.in file and add the line include counties_1872_1991.csv
  2. Edit the setup.py file and add package_data={'cartpy': ['counties_1872_1991.csv']},include_package_data=True to the function setup

Unfortunately, this didn't work for me and I cannot say what I am doing wrong here. I thought is something related to absolute and relative paths, then I tried every possible combination but it didn't work either.

How can I include the csv file in my package?

Lucas
  • 1,166
  • 2
  • 14
  • 34
  • 2
    Does this answer your question? [Access data in package subdirectory](https://stackoverflow.com/questions/779495/access-data-in-package-subdirectory) – jordanm May 24 '20 at 00:57
  • It did. Sorry, I didn't see this question in my earlier research. Thanks! – Lucas May 24 '20 at 12:36

0 Answers0