Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
485 views
in Technique[技术] by (71.8m points)

python - How to fix ImportError: No module named packages.urllib3?

I'm running Python 2.7.6 on an Ubuntu machine. When I run twill-sh (Twill is a browser used for testing websites) in my Terminal, I'm getting the following:

Traceback (most recent call last):
  File "dep.py", line 2, in <module>
    import twill.commands
  File "/usr/local/lib/python2.7/dist-packages/twill/__init__.py", line 52, in <module>
    from shell import TwillCommandLoop
  File "/usr/local/lib/python2.7/dist-packages/twill/shell.py", line 9, in <module>
    from twill import commands, parse, __version__
  File "/usr/local/lib/python2.7/dist-packages/twill/commands.py", line 75, in <module>
    browser = TwillBrowser()
  File "/usr/local/lib/python2.7/dist-packages/twill/browser.py", line 31, in __init__
    from requests.packages.urllib3 import connectionpool as cpl
ImportError: No module named packages.urllib3

However, I can import urllib in Python console just fine. What could be the reason?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

If you already have 'requests' installed from a default build, you may have to

sudo pip install --upgrade requests

Credit to @bkzland from comment on previous answer:

I followed these steps having the same error, I needed to use sudo pip install --upgrade each time to make it work. – bkzland Dec 17 '15 at 12:57

---now, how do I make this a dependency in my setup.py?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...