python - Import error when I try use "requests" module -


i have problem, when try use requests lib

import requests  r = requests.get('http://www.python.org/') print(r) 

after that, got following error

traceback (most recent call last):   file "c:/users/admin/documents/alex/test.py", line 3, in <module>     import requests   file "c:\program files\python3\lib\site-packages\requests\__init__.py", line 53, in <module>     .packages.urllib3.contrib import pyopenssl   file "c:\program files\python3\lib\site-packages\requests\packages\__init__.py", line 27, in <module>     . import urllib3   file "c:\program files\python3\lib\site-packages\requests\packages\urllib3\__init__.py", line 8, in <module>     .connectionpool import (   file "c:\program files\python3\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 35, in <module>     .connection import (   file "c:\program files\python3\lib\site-packages\requests\packages\urllib3\connection.py", line 44, in <module>     .util.ssl_ import (   file "c:\program files\python3\lib\site-packages\requests\packages\urllib3\util\__init__.py", line 20, in <module>     .retry import retry   file "c:\program files\python3\lib\site-packages\requests\packages\urllib3\util\retry.py", line 15, in <module>     log = logging.getlogger(__name__) attributeerror: module 'logging' has no attribute 'getlogger' 

i not understand why @ all. please, me.

your problem 1 of following

  1. your installation of python terribly broken
  2. when c:\program files\python3\lib\site-packages\requests\packages\urllib3\util\retry.py tries import logging imports wrong file. may happen because
    • there file called logging.py in directory running test.py from. in case, need rename logging python library imported, not yours.
    • there file called logging.py in 1 of directories python path , gets found before logging.py module needs

to check logging gets imported, write following simple program

import logging import os.path  print os.path.abspath(logging.__file__) 

whatever printed path logging file. if not along line of ...\python\\python36\\lib\\logging\\__init__.py, wrong file imported , got replace/rename it


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -