SunithaM
SunithaM

Reputation: 71

Path not found in Python

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

Answers (1)

Mitchell Olislagers
Mitchell Olislagers

Reputation: 1827

You need to import Path from pathlib

from pathlib import Path
Path.cwd()

Alternatively,

import pathlib
pathlib.Path.cwd()

Upvotes: 7

Related Questions