Reputation: 71
I have strange issue on environment where i have imported 'pathlib', it says Path is not defined after executing below command in terminal.
>>> import pathlib
>>> Path.cwd()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'Path' is not defined
Thanks
Upvotes: 2
Views: 5852
Reputation: 1827
You need to import Path from pathlib
from pathlib import Path
Path.cwd()
Alternatively,
import pathlib
pathlib.Path.cwd()
Upvotes: 7