简体   繁体   English

Python AttributeError:“模块”对象没有属性“获取”

[英]Python AttributeError: 'module' object has no attribute 'get'

I installed the requests package, but when I start to use it, I got this error : 我安装了请求包,但是当我开始使用它时,出现此错误:

AttributeError: 'module' object has no attribute 'get'

This my code : 这是我的代码:

from bs4 import BeautifulSoup
import requests 

r = requests.get("http://someSite.com/path")

I checked some solution to this problem, and most of them saying that either there is a mistake with importing the package, or that a file with the name requests.py exist in the current directory, but it's not the case for me. 我检查了一些解决此问题的方法,其中大多数人说要么导入软件包有误,要么当前目录中存在一个名为“ requests.py”的文件,但对我而言并非如此。

it's been a while since I got this error, and I stuck with it. 自从出现此错误已经有一段时间了,我坚持了下来。

any idea? 任何想法? thanks. 谢谢。

UPDATE 更新

FULL error message 完整的错误信息

Traceback (most recent call last):
  File "parser.py", line 2, in <module>
    import requests 
  File "/usr/local/lib/python2.7/dist-packages/requests/__init__.py", line 52, in <module>
    from .packages.urllib3.contrib import pyopenssl
  File "/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/contrib/pyopenssl.py", line 47, in <module>
    from cryptography import x509
  File "/usr/local/lib/python2.7/dist-packages/cryptography/x509/__init__.py", line 7, in <module>
    from cryptography.x509.base import (
  File "/usr/local/lib/python2.7/dist-packages/cryptography/x509/base.py", line 14, in <module>
    from cryptography.hazmat.primitives.asymmetric import dsa, ec, rsa
  File "/usr/local/lib/python2.7/dist-packages/cryptography/hazmat/primitives/asymmetric/rsa.py", line 14, in <module>
    from cryptography.hazmat.backends.interfaces import RSABackend
  File "/usr/local/lib/python2.7/dist-packages/cryptography/hazmat/backends/__init__.py", line 7, in <module>
    import pkg_resources
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 76, in <module>
    import parser
  File "/home/lichiheb/Desktop/parser.py", line 4, in <module>
    r = requests.get("http://t...content-available-to-author-only...s.com/search-results-jobs/?searchId=1483197031.949&action=search&page=1&view=list")
AttributeError: 'module' object has no attribute 'get'

Your file is called parser.py which conflicts with a built-in module name parser . 您的文件名为parser.py ,它与内置模块名称parser冲突。

The error message about requests was a weird and unfortunate coincidence. 关于requests的错误消息是一个奇怪而不幸的巧合。 Just rename your module to something else. 只需将模块重命名为其他名称即可。

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

相关问题 AttributeError:&#39;module&#39;对象没有属性&#39;subscribe&#39;Python - AttributeError: 'module' object has no attribute 'subscribe' Python AttributeError:&#39;module&#39;对象没有属性&#39;call&#39;:Python - AttributeError:'module' object has no attribute 'call' :Python Python-&gt; AttributeError:“模块”对象没有属性“主” - Python -> AttributeError: 'module' object has no attribute 'main' python AttributeError:“模块”对象没有属性“ monthcalendar” - python AttributeError: 'module' object has no attribute 'monthcalendar' python 属性错误:“模块”object 没有属性“fft” - python attributeerror: 'module' object has no attribute 'fft' Python:AttributeError:&#39;module&#39;对象没有属性&#39;socketpair&#39; - Python: AttributeError: 'module' object has no attribute 'socketpair' python - AttributeError:&#39;module&#39;对象没有属性&#39;lock&#39; - python - AttributeError: 'module' object has no attribute 'lock' Python错误:AttributeError:&#39;module&#39;对象没有属性 - Python error: AttributeError: 'module' object has no attribute Python AttributeError:“模块”对象没有属性“ Goslate” - Python AttributeError: 'module' object has no attribute 'Goslate' Python:AttributeError:“模块”对象没有属性“ randrange” - Python: AttributeError: 'module' object has no attribute 'randrange'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM