I am running a python project into a virtualenv on Ubuntu 16.04. Until now everything was working as it should, i.e. I could install libraries through pip and listing the installed packages. I am not sure what happened but whenever I try to run pip freeze I get this at the end of python traceback:

File "/home/diego/work/cg/venv/local/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/retry.py", 
line 15, in <module>
log = logging.getLogger(__name__)
AttributeError: 'module' object has no attribute 'getLogger'

Do you have an idea what happened and how can I fix this? thanks

  • Did you activate the virtualenv? – don.joey Jan 30 '17 at 13:48
  • @don.joey Yes with source venev/bin/activate – diegus Jan 30 '17 at 13:52
  • Did you create a file called logging.py? – don.joey Jan 30 '17 at 13:54
  • @don.joey Well, this project actually contains a folder called logging with a file in it called initialize_logging.py – diegus Jan 30 '17 at 13:59
  • I actually solved the problem moving the venv folder to another folder that does not contain subfolder with logging name and it works again – diegus Jan 30 '17 at 14:02

This is because you created a file logging.py or a folder logging that is on the PYTHONPATH and that conflicts with the logging module required for pip to work.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.