i've created a pypi package that have some code that read a text file in it. However when i install my package from pip and import it to my code i get this error:
FileNotFoundError: [Errno 2] No such file or directory: 'file1.txt'
i know that why i have this error but i don't know how to solve it!
how can I read my text file in my package that won't cause a problem for using of the package from the outside?
i did what the answer of this link says: FileNotFoundError: [Errno 2] when packaging for PyPI
but it didn't work and gave me the same result! it gave me the same error. and actually there is indeed no file1.txt in my package folder and the error is correct. can anyone explain how to add it? or is there some other ways?
Here is my package's code and my outside of the package that installed the package's code:
import tensorflow as tf
def printRes():
file1 = open("file1.txt", "r")
sess = tf.compat.v1.Session()
a = tf.constant(int(file1.readline(), 10))
b = tf.constant(int(file1.readline(), 10))
print(sess.run(a + b))
outside:
from file1Text import demo
demo.printRes()
thanks for your help.