Cannot download package possibly because of urllib defaults
See original GitHub issueI’m trying to import fontawesome to a project using Peru 1.3.0.
imports:
fontawesome: deps/font-awesome
curl module fontawesome:
url: https://use.fontawesome.com/releases/v5.15.4/fontawesome-free-5.15.4-web.zip
unpack: zip
But it errors:
$ peru sync
In target "fontawesome":
Error fetching https://use.fontawesome.com/releases/v5.15.4/fontawesome-free-5.15.4-web.zip
HTTP Error 403: Forbidden
I think it’s a urllib problem:
from urllib.error import HTTPError
import urllib.request
url = "https://use.fontawesome.com/releases/v5.15.4/fontawesome-free-5.15.4-web.zip"
try:
req = urllib.request.urlopen(url)
except HTTPError as e:
print(e.headers)
# this will fail and print something
# this succeeds
import urllib3
http = urllib3.PoolManager()
resp = http.request("GET", "https://use.fontawesome.com/releases/v5.15.4/fontawesome-free-5.15.4-web.zip")
print(resp.status)
# succeeds
The urllib request fails but urllib3 succeeds. I don’t think urllib’s HTTPError gives you access to the request headers, so I can’t really tell what’s wrong here. I’m able to retrieve the file with curl, wget, aria2c, and python via urllib3.
Running peru --verbose sync
gave me a stack trace that simply emphasizes “yeah, that’s a 403” and the headers I get back from the request don’t really say what’s wrong. I assume it’s some kind of bot protection on Cloudflare…?
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (8 by maintainers)
Top Results From Across the Web
Cannot import urllib in Python - Stack Overflow
1 Answer 1 · As metioned in the comments, urllib is not installed through pip , it is part of the standard library,...
Read more >HOWTO Fetch Internet Resources Using The urllib Package ...
Often, URLError is raised because there is no network connection (no route to the specified server), or the specified server doesn't exist. In...
Read more >Python's urllib.request for HTTP Requests - Real Python
In this tutorial, you'll be making HTTP requests with Python's built-in urllib.request. You'll try out examples and review common errors ...
Read more >SSL certificate error with pip 21.0.1 · Issue #9568 - GitHub
I have found the root cause of the problem and pip can fix its end. So there are two reasons for this error:...
Read more >URLLib.Request Errors - Esri Community
pip is the mechanism used to get packages, you should check if you have urllib3 installed by opening the python terminal at your...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I tested #219 with the example config and it works! It will fix the problem.
#219 goes with № 3 in that list and pulls the urllib UA directly from a core class that won’t go away. urllib doesn’t — IMO — sufficiently abstract this value 👎