简体   繁体   中英

Why is Pathlib module not found in my venv?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM