Comments (5)
Yes, it's about Geonames service availability, and it would only happen the first run before the dataset is cached locally.
We really need to provide a fallback location for the Geonames data, see #41
from pgeocode.
This seems to be happening fairly regularly to me as well. Is it because the datasets are being updated?
from pgeocode.
Is it? I'm able to run this on a windows build but not in my linux environment.
Successful run:
- Windows 10
- Python3.8.5 64bit
- pgocode 0.2.1
Failed runs:
- ubuntu-latest (github action)
- python:3.8-slim docker container
Related Traceback Snippet:
app/geocode.py:17: in geocode_zipcodes
nomi = pgeocode.Nominatim(country)
/usr/local/lib/python3.8/site-packages/pgeocode.py:71: in __init__
self._data_path, self._data = self._get_data(country)
/usr/local/lib/python3.8/site-packages/pgeocode.py:89: in _get_data
reader, headers = _get_url(url)
/usr/local/lib/python3.8/site-packages/pgeocode.py:40: in _get_url
res = urllib.request.urlopen(url)
/usr/local/lib/python3.8/urllib/request.py:222: in urlopen
return opener.open(url, data, timeout)
/usr/local/lib/python3.8/urllib/request.py:531: in open
response = meth(req, response)
/usr/local/lib/python3.8/urllib/request.py:640: in http_response
response = self.parent.error(
/usr/local/lib/python3.8/urllib/request.py:569: in error
return self._call_chain(*args)
/usr/local/lib/python3.8/urllib/request.py:502: in _call_chain
result = func(*args)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <urllib.request.HTTPDefaultErrorHandler object at 0x7f6634eb0b20>
req = <urllib.request.Request object at 0x7f6634eb0b80>
fp = <http.client.HTTPResponse object at 0x7f6634eb01f0>, code = 404
msg = 'Not Found', hdrs = <http.client.HTTPMessage object at 0x7f6634eb0130>
def http_error_default(self, req, fp, code, msg, hdrs):
> raise HTTPError(req.full_url, code, msg, hdrs, fp)
E urllib.error.HTTPError: HTTP Error 404: Not Found
/usr/local/lib/python3.8/urllib/request.py:649: HTTPError
A quick skim of #40 makes me think that issue was related to the Geonames service availability, but maybe I'm misunderstanding.
from pgeocode.
Maybe I did misunderstand. Reviewing pgeocode
I see that it may be implementing a type of caching using a .txt dump on my local machine -- which would explain the success vs failures.
pgeocode.py
@staticmethod
def _get_data(country):
"""Load the data from disk; otherwise download and save it"""
from zipfile import ZipFile
data_path = os.path.join(STORAGE_DIR, country.upper() + ".txt")
if os.path.exists(data_path):
data = pd.read_csv(data_path, dtype={"postal_code": str})
from pgeocode.
Is it because the datasets are being updated?
It is. They seem to remove old files before generating new ones leading to 404 errors.
See #44 (comment) for a solution that should happen in the near future. I'll close this issue in favor of #44 to avoid duplicates.
from pgeocode.
Related Issues (20)
- Inconsistency in "country code" column name HOT 5
- Throwing HTTP 404 error HOT 8
- Add a fallback data source when https://download.geonames.org/export/zip/{country}.zip fails HOT 3
- Pgeocode | HTTPError: HTTP Error 404: Not Found HOT 4
- Incorrect distance showing HOT 3
- ValueError on CA, UK and IE postcodes
- Include a requirements.txt HOT 2
- Slow performance for Portugal (PT) HOT 1
- [Solved] Import from first hard coded URL fails with "[SSL: CERTIFICATE_VERIFY_FAILED" HOT 7
- latitude indexing bug for _index_postal_codes HOT 1
- Find cities at a specific distance HOT 1
- How can i convert different country code? HOT 2
- country code DZ is not responding HOT 1
- Please Update Countries HOT 1
- Not able to identify few postal codes and find the distances between them for country CA
- ValueError: country=NL_FULL is not a known country code. See the README for a list of supported countries HOT 1
- KeyError: "There is no item named 'DE.txt' in the archive"
- County Code for Naples is NA HOT 3
- Handle detailed postal codes for Morocco
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pgeocode.