gpt4 book ai didi

python - 在 python 中导入请求模块在 OS X 上不起作用

转载 作者:行者123 更新时间:2023-11-28 22:37:49 25 4
gpt4 key购买 nike

我的系统上安装了请求模块。

pip install requests

现在我正在尝试在 rpel 中导入请求

import requests

失败并出现以下错误

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named requests

我找到了这个问题的答案here , 但它没有说明在同一目录中有 python 2.x。

我的终端输出是:

MacBook-Pro:~ tanmaybaranwal$ which python

/usr/bin/python

MacBook-Pro:~ tanmaybaranwal$ which python2.6

/usr/bin/python2.6

MacBook-Pro:~ tanmaybaranwal$ which pip

/usr/local/bin/pip

MacBook-Pro:~ tanmaybaranwal$ sudo pip install python-firebase
Password:
Requirement already satisfied (use --upgrade to upgrade): python-firebase in /Library/Python/2.7/site-packages
Requirement already satisfied (use --upgrade to upgrade): requests>=1.1.0 in ./Library/Python/2.7/lib/python/site-packages (from python-firebase)
Cleaning up...

MacBook-Pro:~ tanmaybaranwal$ sudo pip install requests
Requirement already satisfied (use --upgrade to upgrade): requests in ./Library/Python/2.7/lib/python/site-packages
Cleaning up...

MacBook-Pro:~ tanmaybaranwal$ python
Python 2.7.10 (default, Oct 23 2015, 18:05:06)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

>>> import firebase
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/firebase/__init__.py", line 4, in <module>
from firebase import *
File "/Library/Python/2.7/site-packages/firebase/firebase.py", line 10, in <module>
from .decorators import http_connection
File "/Library/Python/2.7/site-packages/firebase/decorators.py", line 1, in <module>
import requests
ImportError: No module named requests

列出 PIP 模块也没有任何 requests 模块。

最佳答案

为确保您使用正确的 python 通过 pip 安装某些东西,您可以通过 -m 运行它

$ python -m pip install --user requests

(如果您省略 --user 标志,那么您可能需要 root 权限)

关于python - 在 python 中导入请求模块在 OS X 上不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36181102/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com