找不到已安装的模块?

时间:2020-08-21 02:31:27

标签: visual-studio-code pip environment

跟随 https://code.visualstudio.com/docs/python/python-tutorial#_prerequisites 尝试按照建议设置虚拟空间。 当我尝试安装“ matplotlib”时,它说它已经在那里
但是当我去使用它时却找不到!

我错过了什么魔术?

(.venv) C:\Data\Shared_n_synced\Infrequent\VSCode_python\OpenCV>python -m pip install matplotlib
Requirement already satisfied: matplotlib in c:\sww\python\python37\lib\site-packages (3.2.1)
Requirement already satisfied: numpy>=1.11 in c:\sww\python\python37\lib\site-packages (from matplotlib) (1.18.2)
Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in c:\sww\python\python37\lib\site-packages (from matplotlib) (2.4.7)
Requirement already satisfied: cycler>=0.10 in c:\sww\python\python37\lib\site-packages (from matplotlib) (0.10.0)
Requirement already satisfied: python-dateutil>=2.1 in c:\sww\python\python37\lib\site-packages (from matplotlib) (2.8.1)
Requirement already satisfied: kiwisolver>=1.0.1 in c:\sww\python\python37\lib\site-packages (from matplotlib) (1.2.0)
Requirement already satisfied: six in c:\sww\python\python37\lib\site-packages (from cycler>=0.10->matplotlib) (1.14.0)

(.venv) C:\Data\Shared_n_synced\Infrequent\VSCode_python\OpenCV>c:/Data/Shared_n_synced/Infrequent/VSCode_python/OpenCV/.venv/Scripts/python.exe c:/Data/Shared_n_synced/Infrequent/VSCode_python/OpenCV/matplotlib_basic_test1.py
Traceback (most recent call last):
  File "c:/Data/Shared_n_synced/Infrequent/VSCode_python/OpenCV/matplotlib_basic_test1.py", line 1, in <module>
    import matplotlib.pyplot as plt
ModuleNotFoundError: No module named 'matplotlib'

(.venv) C:\Data\Shared_n_synced\Infrequent\VSCode_python\OpenCV>  

预先感谢 JC

1 个答案:

答案 0 :(得分:0)

如果不是答案,则解决方法。 如果从全局环境中卸载了软件包,并重新创建了虚拟环境并将软件包安装在那里,那么它将按预期工作。