Forums

os.mkdir

I am new to pythonanywhere, but I notice that os.mkdir doesn't work in my app, but does work fine in the console. Is there a way to call os.mkdir() from the app script or am I out of luck? Not sure if this matters but I am doing this inside a dropbox synched directory.

Hmm, that should work. What is the exception that you get?

It's: OSError: [Errno 2] No such file or directory: 'dirname'

I found an old post ( https://www.pythonanywhere.com/forums/topic/9/ ) saying that you can't create directories inside a dropbox directory, but like I said, it works fine from the console, so I assume that this issue was at least partly fixed? Also, the person in that post had a different exception...

Hmm. The restriction on creating stuff inside Dropbox directories is that you can't create something inside (eg.) /home/Mordeaux/Dropbox -- that's because the only things that are meant to be in there are a README, an __init__.py, and the folders you've shared with us. So if you're creating something inside /home/Mordeaux/Dropbox/somethingyouveshared then it should be fine.

One possibility: are you giving the full path when you create the directory? If not, it will be creating it relative to whatever the current working directory of your web app is, which could be anywhere. Try with a full path and see if that helps.

The full filepath method works fine. Thanks!

No problem, glad to help!