python - Import error when I try use "requests" module -
this question has answer here:
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
- your installation of python terribly broken
- when
c:\program files\python3\lib\site-packages\requests\packages\urllib3\util\retry.py
tries importlogging
imports wrong file. may happen because- there file called
logging.py
in directory runningtest.py
from. in case, need renamelogging
python library imported, not yours. - there file called
logging.py
in 1 of directories python path , gets found beforelogging.py
module needs
- there file called
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
Post a Comment