I am attempting to publish a package on PyPI (as a newbie) which contains data stored as a pickle file. But I don't seem to be able to read the data in my main code.
My package structure is:
package/
setup.py
MANIFEST.in
package/
package.py
__init__.py
data.pkl
And my code in package.py is somewhat like this:
data = pickle.load(open('data.pkl', 'rb'))
def doSomething(data):
***code to do something on data***
return variable
var = doSomething(data)
When I install the package and try to import it, I get the error:
FileNotFoundError: [Errno 2] No such file or directory: 'data.pkl'
It appears my package.py
can't find my pickle file. Yes, I set include_package_data = True
in setup.py
and the the pickle file is loaded via the MANIFEST.in
file.
I have tried loading the pickle file in __init__.py
or specifying the full path (package/data.pkl
), but none of these work.