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
1 Answer 1
You need to import Path from pathlib
from pathlib import Path
Path.cwd()
Alternatively,
import pathlib
pathlib.Path.cwd()
answered Feb 9, 2021 at 0:15
Mitchell Olislagers
1,8271 gold badge7 silver badges11 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
lang-py