简体   繁体   中英

VSCode ModuleNotFoundError: No module named <...> in Terminal

When I try to import the MWE below from the Terminal in VSCode, I get

ModuleNotFoundError: No module named 'tqdm'

temp.py:

import tqdm

print('hello')

Here is my Terminal session:

(mainenv) Larrys-MBP-5:Desktop larry$ python3
Python 3.9.7 (v3.9.7:1016ef3790, Aug 30 2021, 16:39:15) 
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import temp
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/larry/Desktop/temp.py", line 1, in <module>
    import tqdm
ModuleNotFoundError: No module named 'tqdm'

I'm using a conda environment called mainenv . I can confirm (via conda list ) that tqdm is installed:

在此处输入图像描述

I can also confirm that VSCode is using mainenv as the interpreter:

在此处输入图像描述

I get the same error if I replace tqdm with other packages too, like jsonpickle and tabulate . But if I replace it with numpy or networkx , for example, it works fine.

What's going on here?

Did You Use Pip Or npm? When I try to use npm in vscode for python modules it doesn't work, it works for me when I use pip though.

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