简体   繁体   English

我仍然收到错误ImportError:使用pip3安装请求后,没有模块命名为请求

[英]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.

相关问题 将 requests-html 安装到 pip 和 pip3 后出现“导入错误:没有名为 requests_html 的模块” - "ImportError: No module named requests_html" after installing requests-html to pip and pip3 使用pip安装后,“ImportError:没有名为'requests'的模块” - “ImportError: no module named 'requests'” after installing with pip Python:在pipenv中pip3安装请求之后“没有名为'requests'的模块” - Python: "No module named 'requests' " after pip3 install requests in pipenv 为什么我在安装 pip 后立即收到 ImportError: No module named pip '? - Why am I getting ImportError: No module named pip ' right after installing pip? 尽管安装了它(通过 pip3),尝试运行请求模块仍然不起作用? - Trying to run the requests module still won't work despite installing it (via pip3)? ModuleNotFoundError:即使在“pip3 install requests-html”和“requests_html”之后也没有名为“requests_html”的模块 - ModuleNotFoundError: No module named 'requests_html' even after 'pip3 install requests-html' and 'requests_html' Python:使用pip安装xlrd后“导入错误:没有名为xlrd的模块” - Python: “ImportError: no module named xlrd” after installing xlrd using pip 导入pip3会导致“导入错误:没有名为'pip3'的模块 - Import pip3 results in "ImportError: No module named 'pip3' ImportError:没有名为请求的模块 - ImportError: No module named requests ImportError:没有名为“请求”的模块 - ImportError: No module named 'requests'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM