Pythonista Path Issues
emily_raye last edited by
I am just moving a program that I had previously used on IDLE on Mac to Pythonista and iPad. It pulls files from the directory and reads/writes them. Every time I run this program I get a FileNotFound Error. Even when I use the os.path.abspath() function to determine the file path, then use the open function with the specific path nothing comes up. What folder does my file need to be in to be able to be opened by Pythonista? I’m at the end of my rope. It seems like I’ve tried everything. Any tips would be appreciated!
cvp last edited by cvp
@emily_raye run this little script in any folder of Pythonista, you will see the full name of its path
import sys print(sys.argv)
where the numeric part is the id of your iDevice
ccc last edited by ccc
os.pathis kinda old school.
from pathlib import Path my_data = Path(__file__).resolve().parent / "my_file.txt").read_text()
will read the text from a file in the same directory as this Python file.
JonB last edited by
Are you running your script from an iCloud or external folder perhaps? That is a common problem , that there are a few threads about. IIRC if you want to run from iCloud, you need to create a sub folder.