PosixPath and mkdir exist_ok bugs in notebooks

(karenerobinson) #1

I am getting two errors everywhere that I think must be related to configuration. One is that open() does not accept PosixPaths but rather wants os.PathLike or strings; the other is that mkdir() does not accept an exist_ok flag. Neither makes any sense to me.

Minimal notebook to reproduce:

from fastai.text import *

# generates error:
# TypeError: mkdir() got an unexpected keyword argument 'exist_ok'

# no error
# ok the directory is created, let's try opening a file

# generates error:
# TypeError: expected str, bytes or os.PathLike object, not PosixPath

# no error

Here is some additional info on my system:

I am using an AWS P2.large instance for the course.

fwiw I get the same behavior when running python from a prompt in my ssh shell on the AWS machine.

(fastai) ubuntu@ip-10-0-0-10:$ python --version
Python 3.6.4 :: Anaconda, Inc.

Same answer in the notebook just to be sure:

 import sys
 '3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 18:10:19) \n[GCC 7.2.0]'

(karenerobinson) #2

ok in case this helps anyone else I think the answer was that I had two copies of pathlib:




I think uninstalling and reinstalling pathlib should work, but I manually removed the site-packages file (which didn’t have fspath defined in it—I checked with $cat pathlib.py | grep fspath ) and replaced it with the file that seemed more up to date manually.