Python & requests | ImportError: No module named util

20,387

on pypi.python.org I see, that latest version of requests is 2.2.1

Your listing shows, you have installed version 2.3.0, so it is likely, you are using development version which is not yet really completed.

Uninstal it:

$ pip uninstall requests

And install production quality one:

$ pip install requests

In case, it would still mess up with version 2.3.0, install explicitly the 2.2.1

$ pip install requests==2.2.1
Share:
20,387

Related videos on Youtube

shartshooter
Author by

shartshooter

Learning

Updated on November 14, 2020

Comments

  • shartshooter
    shartshooter over 3 years

    I just installed the package requests on a new computer. I'm getting this error when I try to import that module. Any ideas what's causing the issue w/ the util module?

    Python 2.7.6 (v2.7.6:3a1db0d2747e, Nov 10 2013, 00:42:54) 
    
    [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
    
    Type "help", "copyright", "credits" or "license" for more information.
    
    >>> import requests
    
    Traceback (most recent call last):
    
    File "<stdin>", line 1, in <module>
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests-2.3.0-py2.7.egg/requests/__init__.py", line 58, in <module>
      from . import utils
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests-2.3.0-py2.7.egg/requests/utils.py", line 25, in <module>
      from .compat import parse_http_list as _parse_list_header
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests-2.3.0-py2.7.egg/requests/compat.py", line 7, in <module>
      from .packages import chardet
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests-2.3.0-py2.7.egg/requests/packages/__init__.py", line 3, in <module>
      from . import urllib3
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests-2.3.0-py2.7.egg/requests/packages/urllib3/__init__.py", line 16, in <module>
      from .connectionpool import (
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests-2.3.0-py2.7.egg/requests/packages/urllib3/connectionpool.py", line 36, in <module>
      from .connection import (
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests-2.3.0-py2.7.egg/requests/packages/urllib3/connection.py", line 43, in <module>
      from .util import (
    ImportError: No module named util
    
  • shartshooter
    shartshooter almost 10 years
    I just tried sudo pip uninstall requests and it seemed to go well.I tried installing exactly 2.2.1 and got the same error, so I re-removed requests and tried a test of import requests and got the same error. ImportError: No module named util
  • Jan Vlcinsky
    Jan Vlcinsky almost 10 years
    @user3195487 This is strange. Can you test it using virtualenv? This shall provide very clean environment for such a test.
  • Jan Vlcinsky
    Jan Vlcinsky almost 10 years
    @user3195487 When you do $ pip freeze|grep requests, what version of requests is shown there?
  • shartshooter
    shartshooter almost 10 years
    I figured out the issue. i had installed requests without using pip so I had to manually remove it. Just tried to install pip with your advice and it worked great. Thanks for the help!
  • Jan Vlcinsky
    Jan Vlcinsky almost 10 years
    @user3195487 Great. Learn using pip even for installing development packages - it is very powerful tool, allows installing from pypi, eggs, wheels, from local source directories, from git... And it finally become part of Python in 3.4
  • shartshooter
    shartshooter almost 10 years
    yeah, I'm definitely new to python, unix and pip. Should I always be installing packages w/ sudo pip install packageName? or is there a different way of doing this?
  • Jan Vlcinsky
    Jan Vlcinsky almost 10 years
    @user3195487 We are getting off track. But last recommendation is: install virtualenv and virtualenvwrapper. virtualenv comes with pip installed and allows you to create any number of well isolated development environments. virtualenvwrapper gives you a commands like workon which switch to diferent environemnts.
  • shartshooter
    shartshooter almost 10 years
    Cool, I'll play around with that.
  • Jan Vlcinsky
    Jan Vlcinsky almost 10 years