当我使用python3运行我的脚本时,会出现以下错误:
Traceback (most recent call last): File "rea_scrape.py", line 2, in import requests ModuleNotFoundError: No module named 'requests'
当我运行pip3 install requests时,看起来已经安装了requests。
Requirement already satisfied: requests in /Library/Python/2.7/site-packages (2.18.4) Requirement already satisfied: certifi>=2017.4.17 in /Library/Python/2.7/site-packages (from requests) (2018.4.16) Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /Library/Python/2.7/site-packages (from requests) (3.0.4) Requirement already satisfied: idna<2.7,>=2.5 in /Library/Python/2.7/site-packages (from requests) (2.6) Requirement already satisfied: urllib3<1.23,>=1.21.1 in /Library/Python/2.7/site-packages (from requests) (1.22)
然而,更仔细地查看这些消息似乎表明pip3正在为Python 2.7安装软件包,这不是我的意图。
结果是,使用pip3命令安装的任何内容都无法被导入到由python3运行的脚本中。
我该如何解决这个问题?
FYI,我正在使用MacOS High Sierra。
Traceback (most recent call last): File "rea_scrape.py", line 2, in import requests ModuleNotFoundError: No module named 'requests'
当我运行pip3 install requests时,看起来已经安装了requests。
Requirement already satisfied: requests in /Library/Python/2.7/site-packages (2.18.4) Requirement already satisfied: certifi>=2017.4.17 in /Library/Python/2.7/site-packages (from requests) (2018.4.16) Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /Library/Python/2.7/site-packages (from requests) (3.0.4) Requirement already satisfied: idna<2.7,>=2.5 in /Library/Python/2.7/site-packages (from requests) (2.6) Requirement already satisfied: urllib3<1.23,>=1.21.1 in /Library/Python/2.7/site-packages (from requests) (1.22)
然而,更仔细地查看这些消息似乎表明pip3正在为Python 2.7安装软件包,这不是我的意图。
结果是,使用pip3命令安装的任何内容都无法被导入到由python3运行的脚本中。
我该如何解决这个问题?
FYI,我正在使用MacOS High Sierra。