Why is Pathlib module not found in my venv?
Question:
I tried
>>> import Pathlib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'Pathlib'
I checked from shell
pip install Pathlib
Requirement already satisfied: Pathlib in /Users/milenko/mario/venv/lib/python3.8/site-packages (1.0.1)
How it comes that I can not import this module?
Answers:
Python considers Pathlib
and pathlib
differently.try: pip install pathlib
and import pathlib
if it doesn’t work then try
pip3 install pathlib
pathlib
is part of the standard library for Python 3.4+
.
In my case, I was using the old import line
from Pathlib import Path
Solution
from pathlib import Path
I tried
>>> import Pathlib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'Pathlib'
I checked from shell
pip install Pathlib
Requirement already satisfied: Pathlib in /Users/milenko/mario/venv/lib/python3.8/site-packages (1.0.1)
How it comes that I can not import this module?
Python considers Pathlib
and pathlib
differently.try: pip install pathlib
and import pathlib
if it doesn’t work then try
pip3 install pathlib
pathlib
is part of the standard library for Python 3.4+
.
In my case, I was using the old import line
from Pathlib import Path
Solution
from pathlib import Path