环境出错或者你的IDE需要更新。以exifread作为模块的示例来证明:
(scrape) C:\Users\Admin>python
Python 3.8.5 (default, Sep 3 2020, 21:29:08) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import exifread
>>>
因此,exifread可以在“scrape”环境中导入。
然而,在VSCode中,当您选择一个conda环境时,这个“scrape”环境不像其他环境bd/ml/dl那样显示出来,它是列表中的最后一项,并且末尾没有
('scrape': conda)
。
![enter image description here](https://istack.dev59.com/bE8Ns.webp)
如果我选择这个“scrape”环境,并且之前选择了“bd”环境,它似乎像往常一样工作,它会在状态中被选中。
![enter image description here](https://istack.dev59.com/PYlQm.webp)
但奇怪的是,如果我在那个“scrape”环境中运行一个安装(参考其他答案),我得到:
![enter image description here](https://istack.dev59.com/6qnL7.webp)
或者以书面形式:
from pathlib import Path
!pip install exifread
import exifread
抛出异常:
Requirement already satisfied: exifread in c:\users\admin\anaconda3\envs\bd\lib\site-packages (3.0.0)
因此,Jupyter Notebook没有切换到"scrape"环境,仍然处于之前的"bd"环境。
而且,如果我删除安装命令
!pip install exifread
并运行它,它无法找到模块"exifread",就像问题中的"pandas"一样。
ModuleNotFoundError: No module named 'exifread'
如果我选择其他环境,它就能正常工作。因此,请检查另一个环境或重新构建该环境。
虽然我认为这样可以解决问题,但今天刚刚更新了一下,一切看起来都很新,"scrape" 环境在下拉列表中与其他环境一样被列出来了。
![enter image description here](https://istack.dev59.com/unIj9.webp)
当被选择时,环境现在会弹出在右上角,并且它会运行通过:
![enter image description here](https://istack.dev59.com/FR8MJ.webp)