Throws NameError: name 'pathlib' is not defined with Python 3.4

python, python-3.4, python-3.x

Solution

You used `from .. import ...` statement instead of `import ..`.

Replacing following line:

from pathlib import Path

with:

import pathlib

will solve your problem.

Problem

I was using pathlib module, for directory browsing. Here is the snippet i was trying. ``` import sys,os from pathlib import Path root = "C:\" for path, subdirs, files in os.walk(root): for name in files: print(pathlib.PurePath(path, name)) ``` I get the following exception: "NameError: name 'pathlib' is not defined"

Original source