导入错误:没有模块命名请求 [英] Import Error: No module named requests

查看:26
本文介绍了导入错误:没有模块命名请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道有很多关于此的帖子,我尝试使用提供的解决方案,但无济于事.我尝试了 pip install requestspip install requests --upgrade:

I know there are many posts on this, and I've tried using the solutions provided, but to no avail. I tried pip install requests and pip install requests --upgrade:

pip install requests --upgrade
You are using pip version 7.1.0, however version 7.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Requirement already up-to-date: requests in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages

然后我尝试运行 pip install --upgrade pip,但是当我运行我的文件时,我仍然得到

I then tried running pip install --upgrade pip, yet when I run my file I still get

Import Error: No module named requests

我可以在 PyCharm 中使用请求,所以我不知道是什么原因造成的.有人可以帮忙吗?

I am able to use requests in PyCharm, so I don't know what's causing this. Can someone please help?

推荐答案

您将 requests 安装到不同的 Python 安装中./Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages 是 Mac OS X /usr/bin/python 的 site-packages 目录 安装.

You installed requests into a different Python installation. The /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages is the site-packages directory for the Mac OS X /usr/bin/python installation.

PyCharm 当前未配置为使用该 Python 安装;通过查看您的 PyCharm 设置,或者直接询问 Python:

PyCharm is not currently configured to use that Python installation; check what Python is being used either by looking at your PyCharm settings, or by asking Python directly with:

import sys
print(sys.executable)

请注意,PyCharm 可以处理软件包安装 也适合你;而不是使用命令行 pip 考虑使用 PyCharm,因为在这种情况下它将使用当前配置的 Python 安装.

Note that PyCharm can handle package installations for you as well; rather than use the command line pip consider using PyCharm, as it'll use the currently configured Python installation in that case.

这篇关于导入错误:没有模块命名请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆