Whenever I write:
import pathlib
or
from pathlib import path
I got this:
ImportError: No module named pathlib
I tried also naming it os.path
.
I'm on Python 2.7.14
Is pathlib in Python 2 or only in 3? If it's not available, what else can I use?
Upgrading the Python Version to ( 3.4 +)- Hence we can upgrade our python version from Python 2 to Python 3. This is the most easy way to fix this error no module name pathlib.
Python 3.2 or later is recommended, but pathlib is also usable with Python 2.7 and 2.6.
The pathlib library is included in all versions of python >= 3.4.
pathlib. Path (WindowsPath, PosixPath, etc.) objects are not considered PathLike : PY-30747.
You may install library pathlib2 by the following command:
pip install pathlib2
After that, your import should work:
import pathlib2 as pathlib
If you want to use just standard modules, usage of os.path is also possible, but it has another functions and working differently.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With