Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Pythonista Path Issues
-
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!
-
@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[0])
Something like
/private/var/mobile/Containers/Shared/AppGroup/1B829014-77B3-4446-9B65-034BDDC46F49/Pythonista3/Documents/MyFolder/myscript.py
where the numeric part is the id of your iDevice
-
os.path
is 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.
-
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.