[英]I am still getting the error ImportError: No module named requests after installing requests using pip3
I am using Python 3.6.5 in Visual Studio Code on a Mac. 我在Mac上的Visual Studio Code中使用Python 3.6.5。 I installed pip3 and it is up to date, when I put in the command :
当我输入命令时,我安装了pip3,它是最新的:
$ pip --version
I get this result : 我得到这个结果:
pip 10.0.1 from /usr/local/lib/python3.6/site-packages/pip (python 3.6)
I imported the module requests. 我导入了模块请求。 And when I put in this command :
当我输入以下命令时:
pip freeze | grep requests
I get this result : 我得到这个结果:
requests==2.19.1
So I thought this meant the requests module was installed, but I still get the error ImportError: No module named requests when I put in : import requests in my file and try to run it. 因此,我认为这意味着已安装了请求模块,但我仍然收到错误ImportError:当我放入文件时, 没有名为请求的模块 :在文件中导入请求并尝试运行它。
Can somebody explain what is happening? 有人可以解释发生了什么吗? Thank you :)
谢谢 :)
I found the answer, turns out I was using an extension called Code Runner and I thought it used the integrated terminal, where I had configured Python3. 我找到了答案,原来我正在使用一个名为Code Runner的扩展,并且我认为它使用了集成终端,在该终端中配置了Python3。 But turns out it uses its own interpreter.
但是事实证明,它使用了自己的解释器。 I added the following to my user settings:
我在用户设置中添加了以下内容:
"code-runner.executorMap": {
"python": "python3",
}
and now it works! 现在就可以了! :)
:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.