简体   繁体   English

导入请求不工作Python 3.7

[英]Importing Requests not Working Python 3.7

I'm running the latest Kali Linux with Python 3.7 and am trying to use the requests module. 我正在使用Python 3.7运行最新的Kali Linux并尝试使用请求模块。 As you can see, I install requests but still cannot import it. 如您所见,我安装了请求但仍然无法导入它。 Could someone help me reconcile this strange problem? 有人能帮助我调和这个奇怪的问题吗?

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'

Thanks ahead of time for the help! 提前谢谢你的帮助!

Since it appears you have multiple versions of Python installed you'll need to set your environment to use Python 3.7 (currently it's set to 3.5.6, and requests doesn't appear to be installed). 由于您似乎安装了多个版本的Python您需要将您的环境设置为使用Python 3.7 (目前它已设置为3.5.6,并且似乎未安装请求)。

In your .bash_profile you could probably do: 在你的.bash_profile你可以做到:

alias python3=/path/to/python3.7

which should use the 3.7 version when you enter python3 ... 当你输入python3时应该使用3.7版本...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM