5

I have python 3.5, tried to install logging package in PyCharm, I got an error:

Error occured when installing package 'logging' Make sure that you use a version of Python supported by this package. Currently you are using Python 3.5.

import logging
logging.warning('Watch out!')
logging.info('I told you so') 

UPDATE:

If it is included why I got this:

Traceback (most recent call last):
  File "C:/Users/alotfi/PycharmProjects/firstProj/logging.py", line 1, in <module>
    import logging
  File "C:\Users\alotfi\PycharmProjects\firstProj\logging.py", line 2, in <module>
    logging.warning('Watch out!')
AttributeError: module 'logging' has no attribute 'warning'

Process finished with exit code 1

Thanks.

smottt
  • 3,272
  • 11
  • 37
  • 44
user1034127
  • 349
  • 3
  • 5
  • 14
  • 1
    What do you mean by 'installing' logging? It's a module in the standard library included in a base install.... – Dan Sep 29 '15 at 15:41
  • I have exactly the same error when running exactly the same examples. I have no idea why the error occurred. This question shouldn't be closed. It is very clear. Why the error occurred if it is standard library? – tomasz74 May 22 '16 at 18:58
  • you named your file `logging.py`, the interpreter is looking for an attribute `warning` in your file, not in the module you intended to import – Joey Baruch May 14 '21 at 01:32

1 Answers1

6

Logging is a standard package for python 3.5 this means that there is no reason to install it.

shuttle87
  • 15,466
  • 11
  • 77
  • 106
dmr
  • 526
  • 2
  • 8
  • APDATED my question, if it's included why I got that error ? – user1034127 Sep 29 '15 at 16:46
  • always the same : AttributeError: module 'logging' has no attribute 'warn' – user1034127 Sep 29 '15 at 17:26
  • 1
    This answer explains nothing. The Logging module is a standard package and still running first example from documentation gives an error like logging wouldn't be installed. WHY? – tomasz74 May 22 '16 at 19:00
  • 6
    Well, the real answer seems to be quite simple: @user1034127, @tomasz74: The original poster seems to have saved his example script as `logging.py`. That's why it fails. Never give a script the same name as an existing module. If you `import logging`, you just import your own script. Give it another name and cheer up. – absurd Mar 07 '17 at 13:31
  • @absurd, you are completely right. answer seems odd is simply because author modified question after I posted my answer. – dmr Jun 02 '21 at 18:16