5
I’m creating a Python package where one of my programs needs to open a text file to read some information. This file is in the same directory as my source. When I run the program in the interpreter I simply do
with open("AtomProva.atp") as f:
input = f.readlines()
and he opens the file normally. However, when I create a package that runs this program it gives the following error
Filenotfounderror: [Errno 2] No such file or directory: 'Atomprova.atp'
How do I find this file by running my function from within the package I’m creating?
I don’t know how it is to create packages but surely you have a path problem. In your code you pass a relative path of a file in the same folder as yours. py, at the time it will run the package it looks elsewhere (I don’t know exactly which). Pass more details of what it is and how uses this package that can reach the solution.
– Math
It is a simple package (a folder with a init.py, your script plus your . atp) or a package generated with setuptools?
– ppalacios