2

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

7

You need to import Path from pathlib

from pathlib import Path
Path.cwd()

Alternatively,

import pathlib
pathlib.Path.cwd()
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.