简体   繁体   English

Python没有命名模块的串行/没有命名模块的请求

[英]Python no module named serial / no module named requests

This is the second time today this has happened.. 这是今天第二次发生这种情况。

I tried to import requests earlier and I got an Import Error: no module named requests 我尝试更早地导入请求,但出现导入错误:没有名为请求的模块

Same thing for serial 串行相同

I googled the crap out of this and nothing I've found works. 我用谷歌搜索了这个废话,但我发现没有任何效果。 Any ideas as to what's going on? 有什么想法吗? I'm trying to use pyserial to take input from an arduino 我正在尝试使用pyserial从arduino输入

pip install requests
pip install pyserial

should do it (unless you don't have pip installed) 应该这样做(除非您没有安装pip)

are you looking for urllib.requests? 您在寻找urllib.requests吗? if you are using python 2.7 when you ask for requests you import urllib and you don't actually use request, but its methods are available to the urllib handle, so for instance: 如果您在请求请求时使用的是python 2.7,则可以导入urllib,但实际上并没有使用request,但是urllib句柄可以使用它的方法,例如:

urllib.urlopen("http://google.com")

will work in python 2.7.x, where 将在python 2.7.x中工作,其中

urllib.request.urlopen("http://google.com")

will work in python3.xx 将在python3.xx中工作

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

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