Python requests and beautifulsoup module not importing


I have installed python in my mac. When I type python3in terminal and then import requests and bs4 it imports it and run the program correctly. But when I run it on python file as python3, it gives the following error:

 import requests
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/requests/", line 52, in <module>
    from .packages.urllib3.contrib import pyopenssl
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/requests/packages/", line 27, in <module>
    from . import urllib3
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/requests/packages/urllib3/", line 8, in <module>
    from .connectionpool import (
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/requests/packages/urllib3/", line 3, in <module>
    import logging
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/logging/", line 28, in <module>
    from string import Template
  File "/Users/dark_archer/Desktop/src/", line 1, in <module>
ValueError: not enough values to unpack (expected 2, got 0)

I got the same error with both python 3.5 and python 3.6.

Show source
| osx   | python   | python-3.x   | beautifulsoup   | python-requests   2016-12-29 08:12 1 Answers

Answers to Python requests and beautifulsoup module not importing ( 1 )

  1. 2016-12-29 08:12

    The issue is that you named a module so it's confusing the importer because the logging module is also trying to import something from the standard library module This causes an issue known as "name shadowing" where your locally defined module is loaded instead of the the standard library module.

    When your version of gets imported it triggers the code which is causing your error.

    As an easy fix, try to rename your module to something else.

    For more info on name shadowing check out the "The name shadowing trap" section of this link:

Leave a reply to - Python requests and beautifulsoup module not importing

◀ Go back