Установка urllib2 python windows

installing urllib in Python3.6

I would like to import urllib to use the function ‘request’. However, I encountered an error when trying to do so. I tried pip install urllib but still had the same error. I am using Python 3.6. Really appreciate any help.

i do import urllib.request using this code:

but it gives me this error: ModuleNotFoundError: No Module named ‘urllib.parse’; ‘urllib’ is not a package

5 Answers 5

urllib is a standard library, you do not have to install it. Simply import urllib

The corrected code is

running the code above produces

urllib is a standard python library (built-in) so you don’t have to install it. just import it if you need to use request by:

if it’s not work maybe you compiled python in wrong way, so be kind and give us more details.

This happens because your local module named urllib.py shadows the installed requests module you are trying to use. The current directory is preapended to sys.path, so the local name takes precedence over the installed name.

An extra debugging tip when this comes up is to look at the Traceback carefully, and realize that the name of your script in question is matching the module you are trying to import.

urllib3 1.26.4

pip install urllib3 Copy PIP instructions

Released: Mar 15, 2021

HTTP library with thread-safe connection pooling, file post, and more.

  • Homepage
  • Issue tracker
  • Code
  • Documentation

Statistics

View statistics for this project via Libraries.io, or by using our public dataset on Google BigQuery

License: MIT License (MIT)

Tags urllib, httplib, threadsafe, filepost, http, https, ssl, pooling

Classifiers

  • Environment
    • Web Environment
  • Intended Audience
    • Developers
  • License
    • OSI Approved :: MIT License
  • Operating System
    • OS Independent
  • Programming Language
    • Python
    • Python :: 2
    • Python :: 2.7
    • Python :: 3
    • Python :: 3.5
    • Python :: 3.6
    • Python :: 3.7
    • Python :: 3.8
    • Python :: 3.9
    • Python :: Implementation :: CPython
    • Python :: Implementation :: PyPy
  • Topic
    • Internet :: WWW/HTTP
    • Software Development :: Libraries

Project description

urllib3 is a powerful, user-friendly HTTP client for Python. Much of the Python ecosystem already uses urllib3 and you should too. urllib3 brings many critical features that are missing from the Python standard libraries:

  • Thread safety.
  • Connection pooling.
  • Client-side SSL/TLS verification.
  • File uploads with multipart encoding.
  • Helpers for retrying requests and dealing with HTTP redirects.
  • Support for gzip, deflate, and brotli encoding.
  • Proxy support for HTTP and SOCKS.
  • 100% test coverage.

urllib3 is powerful and easy to use:

Installing

urllib3 can be installed with pip:

Alternatively, you can grab the latest source code from GitHub:

Читайте также:  Windows 10 это genesis

Documentation

urllib3 has usage and reference documentation at urllib3.readthedocs.io.

Contributing

urllib3 happily accepts contributions. Please see our contributing documentation for some tips on getting started.

Security Disclosures

To report a security vulnerability, please use the Tidelift security contact. Tidelift will coordinate the fix and disclosure with maintainers.

Maintainers

  • @sethmlarson (Seth M. Larson)
  • @pquentin (Quentin Pradet)
  • @theacodes (Thea Flowers)
  • @haikuginger (Jess Shapiro)
  • @lukasa (Cory Benfield)
  • @sigmavirus24 (Ian Stapleton Cordasco)
  • @shazow (Andrey Petrov)

Sponsorship

If your company benefits from this library, please consider sponsoring its development.

For Enterprise

Professional support for urllib3 is available as part of the Tidelift Subscription. Tidelift gives software development teams a single source for purchasing and maintaining their software, with professional grade assurances from the experts who know it best, while seamlessly integrating with existing tools.

Changes

1.26.4 (2021-03-15)

  • Changed behavior of the default SSLContext when connecting to HTTPS proxy during HTTPS requests. The default SSLContext now sets check_hostname=True.

1.26.3 (2021-01-26)

  • Fixed bytes and string comparison issue with headers (Pull #2141)
  • Changed ProxySchemeUnknown error message to be more actionable if the user supplies a proxy URL without a scheme. (Pull #2107)

1.26.2 (2020-11-12)

  • Fixed an issue where wrap_socket and CERT_REQUIRED wouldn’t be imported properly on Python 2.7.8 and earlier (Pull #2052)

1.26.1 (2020-11-11)

  • Fixed an issue where two User-Agent headers would be sent if a User-Agent header key is passed as bytes (Pull #2047)

1.26.0 (2020-11-10)

  • NOTE: urllib3 v2.0 will drop support for Python 2. Read more in the v2.0 Roadmap.
  • Added support for HTTPS proxies contacting HTTPS servers (Pull #1923, Pull #1806)
  • Deprecated negotiating TLSv1 and TLSv1.1 by default. Users that still wish to use TLS earlier than 1.2 without a deprecation warning should opt-in explicitly by setting ssl_version=ssl.PROTOCOL_TLSv1_1 (Pull #2002) Starting in urllib3 v2.0: Connections that receive a «DeprecationWarning« will fail
  • Deprecated Retry options Retry.DEFAULT_METHOD_WHITELIST, Retry.DEFAULT_REDIRECT_HEADERS_BLACKLIST and Retry(method_whitelist=. ) in favor of Retry.DEFAULT_ALLOWED_METHODS, Retry.DEFAULT_REMOVE_HEADERS_ON_REDIRECT, and Retry(allowed_methods=. ) (Pull #2000) Starting in urllib3 v2.0: Deprecated options will be removed
  • Added default User-Agent header to every request (Pull #1750)
  • Added urllib3.util.SKIP_HEADER for skipping User-Agent , Accept-Encoding , and Host headers from being automatically emitted with requests (Pull #2018)
  • Collapse transfer-encoding: chunked request data and framing into the same socket.send() call (Pull #1906)
  • Send http/1.1 ALPN identifier with every TLS handshake by default (Pull #1894)
  • Properly terminate SecureTransport connections when CA verification fails (Pull #1977)
  • Don’t emit an SNIMissingWarning when passing server_hostname=None to SecureTransport (Pull #1903)
  • Disabled requesting TLSv1.2 session tickets as they weren’t being used by urllib3 (Pull #1970)
  • Suppress BrokenPipeError when writing request body after the server has closed the socket (Pull #1524)
  • Wrap ssl.SSLError that can be raised from reading a socket (e.g. “bad MAC”) into an urllib3.exceptions.SSLError (Pull #1939)

1.25.11 (2020-10-19)

  • Fix retry backoff time parsed from Retry-After header when given in the HTTP date format. The HTTP date was parsed as the local timezone rather than accounting for the timezone in the HTTP date (typically UTC) (Pull #1932, Pull #1935, Pull #1938, Pull #1949)
  • Fix issue where an error would be raised when the SSLKEYLOGFILE environment variable was set to the empty string. Now SSLContext.keylog_file is not set in this situation (Pull #2016)
Читайте также:  Error 1722 the windows installer package

1.25.10 (2020-07-22)

  • Added support for SSLKEYLOGFILE environment variable for logging TLS session keys with use with programs like Wireshark for decrypting captured web traffic (Pull #1867)
  • Fixed loading of SecureTransport libraries on macOS Big Sur due to the new dynamic linker cache (Pull #1905)
  • Collapse chunked request bodies data and framing into one call to send() to reduce the number of TCP packets by 2-4x (Pull #1906)
  • Don’t insert None into ConnectionPool if the pool was empty when requesting a connection (Pull #1866)
  • Avoid hasattr call in BrotliDecoder.decompress() (Pull #1858)

1.25.9 (2020-04-16)

Added InvalidProxyConfigurationWarning which is raised when erroneously specifying an HTTPS proxy URL. urllib3 doesn’t currently support connecting to HTTPS proxies but will soon be able to and we would like users to migrate properly without much breakage.

See this GitHub issue for more information on how to fix your proxy config. (Pull #1851)

Drain connection after PoolManager redirect (Pull #1817)

Ensure load_verify_locations raises SSLError for all backends (Pull #1812)

Rename VerifiedHTTPSConnection to HTTPSConnection (Pull #1805)

Allow the CA certificate data to be passed as a string (Pull #1804)

Raise ValueError if method contains control characters (Pull #1800)

Add __repr__ to Timeout (Pull #1795)

1.25.8 (2020-01-20)

  • Drop support for EOL Python 3.4 (Pull #1774)
  • Optimize _encode_invalid_chars (Pull #1787)

1.25.7 (2019-11-11)

  • Preserve chunked parameter on retries (Pull #1715, Pull #1734)
  • Allow unset SERVER_SOFTWARE in App Engine (Pull #1704, Issue #1470)
  • Fix issue where URL fragment was sent within the request target. (Pull #1732)
  • Fix issue where an empty query section in a URL would fail to parse. (Pull #1732)
  • Remove TLS 1.3 support in SecureTransport due to Apple removing support (Pull #1703)

1.25.6 (2019-09-24)

) characters were incorrectly percent-encoded in the path. (Pull #1692)

1.25.5 (2019-09-19)

  • Add mitigation for BPO-37428 affecting Python http:// and https:// schemes: for schemes it does not recognise, it assumes they are case-sensitive and leaves them unchanged. (Issue #1080)

1.20 (2017-01-19)

  • Added support for waiting for I/O using selectors other than select, improving urllib3’s behaviour with large numbers of concurrent connections. (Pull #1001)
  • Updated the date for the system clock check. (Issue #1005)
  • ConnectionPools now correctly consider hostnames to be case-insensitive. (Issue #1032)
  • Outdated versions of PyOpenSSL now cause the PyOpenSSL contrib module to fail when it is injected, rather than at first use. (Pull #1063)
  • Outdated versions of cryptography now cause the PyOpenSSL contrib module to fail when it is injected, rather than at first use. (Issue #1044)
  • Automatically attempt to rewind a file-like body object when a request is retried or redirected. (Pull #1039)
  • Fix some bugs that occur when modules incautiously patch the queue module. (Pull #1061)
  • Prevent retries from occurring on read timeouts for which the request method was not in the method whitelist. (Issue #1059)
  • Changed the PyOpenSSL contrib module to lazily load idna to avoid unnecessarily bloating the memory of programs that don’t need it. (Pull #1076)
  • Add support for IPv6 literals with zone identifiers. (Pull #1013)
  • Added support for socks5h:// and socks4a:// schemes when working with SOCKS proxies, and controlled remote DNS appropriately. (Issue #1035)
Читайте также:  Мигает экран монитора что делать windows 10 после обновления

1.19.1 (2016-11-16)

  • Fixed AppEngine import that didn’t function on Python 3.5. (Pull #1025)

1.19 (2016-11-03)

  • urllib3 now respects Retry-After headers on 413, 429, and 503 responses when using the default retry logic. (Pull #955)
  • Remove markers from setup.py to assist ancient setuptools versions. (Issue #986)
  • Disallow superscripts and other integerish things in URL ports. (Issue #989)
  • Allow urllib3’s HTTPResponse.stream() method to continue to work with non-httplib underlying FPs. (Pull #990)
  • Empty filenames in multipart headers are now emitted as such, rather than being suppressed. (Issue #1015)
  • Prefer user-supplied Host headers on chunked uploads. (Issue #1009)

1.18.1 (2016-10-27)

CVE-2016-9015. Users who are using urllib3 version 1.17 or 1.18 along with PyOpenSSL injection and OpenSSL 1.1.0 must upgrade to this version. This release fixes a vulnerability whereby urllib3 in the above configuration would silently fail to validate TLS certificates due to erroneously setting invalid flags in OpenSSL’s SSL_CTX_set_verify function. These erroneous flags do not cause a problem in OpenSSL versions before 1.1.0, which interprets the presence of any flag as requesting certificate validation.

There is no PR for this patch, as it was prepared for simultaneous disclosure and release. The master branch received the same fix in Pull #1010.

Need to install urllib2 for Python 3.5.1

I’m running Python 3.5.1 for Mac. I want to use urllib2 module. I tried installing it but I was told that it’s been split into urllib.request and urllib.error for Python 3.

My command (running from the framework bin directory for now because it’s not in my path):

I got the same error before when I tried to install urllib2 in one fell swoop.

3 Answers 3

WARNING: Security researches have found several poisoned packages on PyPI, including a package named urllib , which will ‘phone home’ when installed. If you used pip install urllib some time after June 2017, remove that package as soon as possible.

You can’t, and you don’t need to.

urllib2 is the name of the library included in Python 2. You can use the urllib.request library included with Python 3, instead. The urllib.request library works the same way urllib2 works in Python 2. Because it is already included you don’t need to install it.

If you are following a tutorial that tells you to use urllib2 then you’ll find you’ll run into more issues. Your tutorial was written for Python 2, not Python 3. Find a different tutorial, or install Python 2.7 and continue your tutorial on that version. You’ll find urllib2 comes with that version.

Alternatively, install the requests library for a higher-level and easier to use API. It’ll work on both Python 2 and 3.

Оцените статью