简体   繁体   English

为什么在我的 venv 中找不到 Pathlib 模块?

[英]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我从 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 Python 不同地考虑Pathlibpathlib 。尝试: pip install pathlibimport pathlib如果它不起作用然后尝试pip3 install pathlib

pathlib is part of the standard library for Python 3.4+ . pathlibPython 3.4+标准库的一部分。

In my case, I was using the old import line就我而言,我使用的是旧的导入线

from Pathlib import Path

Solution解决方案

from pathlib import Path

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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