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

后端 未结 5 1695
既然无缘
既然无缘 2020-12-11 01:09

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:

相关标签:
5条回答
  • 2020-12-11 01:51

    python3

    #note that requests.packages.urllib3 is just an alias for urllib3
    from urllib3 import disable_warnings
    from urllib3.exceptions import InsecureRequestWarning
    disable_warnings(InsecureRequestWarning)
    
    0 讨论(0)
  • 2020-12-11 01:52

    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?

    0 讨论(0)
  • 2020-12-11 01:55

    Problem solved by:

    pip install --upgrade urllib3==1.19.1
    pip install --upgrade requests
    
    0 讨论(0)
  • 2020-12-11 01:59

    If you are having a RHEL based flavour, then:

    yum install -y python-requests

    Debian/Ubuntu based flavour:

    apt-get install -y python-requests

    Arch Linux based flavour:

    pacman -S python-requests

    0 讨论(0)
  • 2020-12-11 02:00

    There is a difference between the standard urllib and urllib2 and the third-party urllib3.

    It looks like twill does not install the dependencies so you have to do it yourself. Twill depends on requests library which comes with and uses urllib3 behind the scenes. You also need lxml and cssselect libraries.

    You can install them on terminal as follows:

    pip install requests

    pip install lxml

    and

    pip install cssselect

    0 讨论(0)
提交回复
热议问题