猿问

导入请求不起作用 Python 3.7

我正在使用 Python 3.7 运行最新的 Kali Linux,并尝试使用 requests 模块。如您所见,我安装了请求,但仍然无法导入它。有人能帮我解决这个奇怪的问题吗?


root@kali:~/Desktop# pip3 install --upgrade requests


Requirement already up-to-date: requests in 

/usr/local/lib/python3.7/site-packages (2.20.1)

Requirement already satisfied, skipping upgrade: urllib3<1.25,>=1.21.1 

in /usr/local/lib/python3.7/site-packages (from requests) (1.23)

Requirement already satisfied, skipping upgrade: chardet<3.1.0,>=3.0.2 in /usr/local/lib/python3.7/site-packages (from requests) (3.0.4)

Requirement already satisfied, skipping upgrade: certifi>=2017.4.17 in /usr/local/lib/python3.7/site-packages (from requests) (2018.10.15)

Requirement already satisfied, skipping upgrade: idna<2.8,>=2.5 in /usr/local/lib/python3.7/site-packages (from requests) (2.7)


root@kali:~/Desktop# python3


Python 3.5.6 (default, Sep 29 2018, 21:41:04) 

[GCC 8.2.0] on linux

Type "help", "copyright", "credits" or "license" for more information.

>>> import requests

Traceback (most recent call last):

  File "<stdin>", line 1, in <module>

ImportError: No module named 'requests'

提前感谢您的帮助!


森栏
浏览 154回答 1
1回答

料青山看我应如是

由于您似乎Python安装了多个版本,因此您需要设置要使用的环境Python 3.7(当前设置为 3.5.6,并且似乎未安装 requests)。在你.bash_profile可能会这样做:alias&nbsp;python3=/path/to/python3.7输入时应使用 3.7 版本python3...
随时随地看视频慕课网APP

相关分类

Python
我要回答