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
Related videos on Youtube
Comments
-
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 almost 10 yearsI 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 ofimport requests
and got the same error.ImportError: No module named util
-
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 almost 10 years@user3195487 When you do
$ pip freeze|grep requests
, what version of requests is shown there? -
shartshooter almost 10 yearsI 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 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 almost 10 yearsyeah, 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 almost 10 years@user3195487 We are getting off track. But last recommendation is: install
virtualenv
andvirtualenvwrapper
.virtualenv
comes withpip
installed and allows you to create any number of well isolated development environments.virtualenvwrapper
gives you a commands likeworkon
which switch to diferent environemnts. -
shartshooter almost 10 yearsCool, I'll play around with that.
-
Jan Vlcinsky almost 10 years