Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 导入错误:导入错误:没有名为请求的模块_Python_Python 2.7_Import_Module_Urllib - Fatal编程技术网

Python 导入错误:导入错误:没有名为请求的模块

Python 导入错误:导入错误:没有名为请求的模块,python,python-2.7,import,module,urllib,Python,Python 2.7,Import,Module,Urllib,我不熟悉python和Web垃圾。我正在使用linux mint 18.2和python 2.7.12。 我正在尝试导入并最终使用beautifulsoup执行urllib.request,但最终失败了。在stackoverflow参考之后,我使用-sudo apt get安装python请求安装了请求模块。运行成功 因此,请查看我执行的所有尝试和错误(到目前为止都没有成功),并帮助我执行urllib.request。谢谢 >>> import bs4 >>>

我不熟悉python和Web垃圾。我正在使用linux mint 18.2和python 2.7.12。 我正在尝试导入并最终使用beautifulsoup执行urllib.request,但最终失败了。在stackoverflow参考之后,我使用-sudo apt get安装python请求安装了请求模块。运行成功

因此,请查看我执行的所有尝试和错误(到目前为止都没有成功),并帮助我执行urllib.request。谢谢

>>> import bs4
>>> pip install urllib
SyntaxError: invalid syntax
>>> import urlihb

Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
    import urlihb
ImportError: No module named urlihb
>>> import urllib
>>> from urllib.request import urlopen as newreq

Traceback (most recent call last):
  File "<pyshell#4>", line 1, in <module>
    from urllib.request import urlopen as newreq
ImportError: No module named request
>>> import urllib2
>>> from urllib2.request import urlopen as newreq

Traceback (most recent call last):
  File "<pyshell#6>", line 1, in <module>
    from urllib2.request import urlopen as newreq
ImportError: No module named request
>>> sudo pip install request
SyntaxError: invalid syntax
>>> sudo install request
SyntaxError: invalid syntax
>>> sudp pip install requests
SyntaxError: invalid syntax
>>> sudo pip install requests
SyntaxError: invalid syntax
>>> sudo install requests
SyntaxError: invalid syntax
>>> import urllib2
>>> from urllib2.request import urlopen as newreq

Traceback (most recent call last):
  File "<pyshell#13>", line 1, in <module>
    from urllib2.request import urlopen as newreq
ImportError: No module named request
>>> from urllib2.requests import urlopen as newreq

Traceback (most recent call last):
  File "<pyshell#14>", line 1, in <module>
    from urllib2.requests import urlopen as newreq
ImportError: No module named requests
>>> import urllib3.request import urlopen as newreq
SyntaxError: invalid syntax
>>> import urllib2.request

Traceback (most recent call last):
  File "<pyshell#16>", line 1, in <module>
    import urllib2.request
ImportError: No module named request
>>> urllib2.requests

Traceback (most recent call last):
  File "<pyshell#17>", line 1, in <module>
    urllib2.requests
AttributeError: 'module' object has no attribute 'requests'
>>> import urllib2.requests

Traceback (most recent call last):
  File "<pyshell#18>", line 1, in <module>
    import urllib2.requests
ImportError: No module named requests
>>> import urllib2.request

Traceback (most recent call last):
  File "<pyshell#19>", line 1, in <module>
    import urllib2.request
ImportError: No module named request
>>> import urllib.reques

Traceback (most recent call last):
  File "<pyshell#20>", line 1, in <module>
    import urllib.reques
ImportError: No module named reques
>>> import urllib.request

Traceback (most recent call last):
  File "<pyshell#21>", line 1, in <module>
    import urllib.request
ImportError: No module named request
>>> import beautifulsoup

Traceback (most recent call last):
  File "<pyshell#22>", line 1, in <module>
    import beautifulsoup
ImportError: No module named beautifulsoup
>>> import beautifullsoup as bs4

Traceback (most recent call last):
  File "<pyshell#23>", line 1, in <module>
    import beautifullsoup as bs4
ImportError: No module named beautifullsoup
>>> import bs4
>>> import urllib.request

Traceback (most recent call last):
  File "<pyshell#25>", line 1, in <module>
    import urllib.request
ImportError: No module named request
>>> import urllib2.request

Traceback (most recent call last):
  File "<pyshell#26>", line 1, in <module>
    import urllib2.request
ImportError: No module named request
>>> import urllib.requests

Traceback (most recent call last):
  File "<pyshell#27>", line 1, in <module>
    import urllib.requests
ImportError: No module named requests
>>> import urllib2.requests

Traceback (most recent call last):
  File "<pyshell#28>", line 1, in <module>
    import urllib2.requests
ImportError: No module named requests
>>> 
导入bs4 >>>pip安装urllib SyntaxError:无效语法 >>>导入urlihb 回溯(最近一次呼叫最后一次): 文件“”,第1行,在 导入urlihb ImportError:没有名为urlihb的模块 >>>导入URL库 >>>从urllib.request导入urlopen作为newreq 回溯(最近一次呼叫最后一次): 文件“”,第1行,在 从urllib.request导入urlopen作为newreq ImportError:没有名为request的模块 >>>导入urllib2 >>>从urllib2.request导入urlopen作为newreq 回溯(最近一次呼叫最后一次): 文件“”,第1行,在 从urllib2.request导入urlopen作为newreq ImportError:没有名为request的模块 >>>sudopip安装请求 SyntaxError:无效语法 >>>sudo安装请求 SyntaxError:无效语法 >>>sudp pip安装请求 SyntaxError:无效语法 >>>sudopip安装请求 SyntaxError:无效语法 >>>sudo安装请求 SyntaxError:无效语法 >>>导入urllib2 >>>从urllib2.request导入urlopen作为newreq 回溯(最近一次呼叫最后一次): 文件“”,第1行,在 从urllib2.request导入urlopen作为newreq ImportError:没有名为request的模块 >>>从urllib2.requests将urlopen作为newreq导入 回溯(最近一次呼叫最后一次): 文件“”,第1行,在 从urllib2.requests将urlopen作为newreq导入 ImportError:没有名为请求的模块 >>>导入urlib3.request导入urlopen为newreq SyntaxError:无效语法 >>>导入urllib2.0请求 回溯(最近一次呼叫最后一次): 文件“”,第1行,在 导入urllib2.0请求 ImportError:没有名为request的模块 >>>urllib2.1请求 回溯(最近一次呼叫最后一次): 文件“”,第1行,在 urllib2.1请求 AttributeError:“模块”对象没有属性“请求” >>>导入urllib2.0请求 回溯(最近一次呼叫最后一次): 文件“”,第1行,在 导入urllib2.0请求 ImportError:没有名为请求的模块 >>>导入urllib2.0请求 回溯(最近一次呼叫最后一次): 文件“”,第1行,在 导入urllib2.0请求 ImportError:没有名为request的模块 >>>导入urllib.reques 回溯(最近一次呼叫最后一次): 文件“”,第1行,在 导入urllib.reques ImportError:没有名为reques的模块 >>>导入urllib.request 回溯(最近一次呼叫最后一次): 文件“”,第1行,在 导入urllib.request ImportError:没有名为request的模块 >>>进口美联 回溯(最近一次呼叫最后一次): 文件“”,第1行,在 进口美联 ImportError:没有名为beautifulsoup的模块 >>>以bs4的形式导入 回溯(最近一次呼叫最后一次): 文件“”,第1行,在 以bs4的形式导入 ImportError:没有名为beautifullsoup的模块 >>>进口bs4 >>>导入urllib.request 回溯(最近一次呼叫最后一次): 文件“”,第1行,在 导入urllib.request ImportError:没有名为request的模块 >>>导入urllib2.0请求 回溯(最近一次呼叫最后一次): 文件“”,第1行,在 导入urllib2.0请求 ImportError:没有名为request的模块 >>>导入urllib.requests 回溯(最近一次呼叫最后一次): 文件“”,第1行,在 导入urllib.requests ImportError:没有名为请求的模块 >>>导入urllib2.0请求 回溯(最近一次呼叫最后一次): 文件“”,第1行,在 导入urllib2.0请求 ImportError:没有名为请求的模块 >>> 您所需要的只是:“导入urllib.request”


在运行“pip安装urllib”

a)之后,您不能像这样在解释器中运行
pip
。在你的系统外壳中运行它!b) 您必须正确键入命令和名称,不能有拼写错误。因此,当您想使用pip安装新东西时,您必须在cmd中进行,最好是作为管理员(否则
访问被拒绝
可能会弹出)1)sudo apt install python pip;2) 安装升级pip;3) sudopip安装工具;4) sudo pip install bs4这是我执行的命令序列。导入urllib.request成功失败,我将稍后检查并更新。谢谢!当我在pythonidle(2.7.12)中使用导入请求时,我尝试测试我的suo-pip安装请求是否工作正常。它引发了以下错误:-警告(来自警告模块):文件“/usr/local/lib/python2.7/dist-packages/requests/_-init___;.py”,第80行RequestsDependencyWarning)RequestsDependencyWarning:urllib3(1.13.1)或chardet(2.3.0)与支持的版本不匹配!还相继抛出了另一个错误(请帮助我)-回溯(最近一次调用最后一次):导入请求文件“/usr/local/lib/python2.7/dist packages/requests/_init__;.py”第90行中的导入请求文件“/usr/local/lib/python2.7/dist packages/requests/_u init____;.py”中的