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

asked Feb 9, 2021 at 0:12

1 Answer 1

7

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.