Comments (4)
What happens when you run:
import sys; print(sys.getfilesystemencoding())
import locale; print(locale.getpreferredencoding())
Is your OS set to use utf-8 for both of those encodings?
I thought Python on all platforms was defaulting to utf-8 since like 3.6 (see PEP 528 and 529)... but maybe it's somehow still opt-in on Windows (see PEP 540)?
from osmnx.
Here's another test for you:
from pathlib import Path
with Path("kaliningrad.xml").open() as f:
print(f)
The file is encoded as utf-8 and the XML declaration states that it is utf-8... does your system open it with utf-8 encoding or does it print some other encoding instead?
from osmnx.
Thanks Geoff,
Interesting, those tests are quite revealing:
import sys; print(f"File System Encoding: {sys.getfilesystemencoding()}")
import locale; print(f"Preferred encoding: {locale.getpreferredencoding()}")
from pathlib import Path
with Path("./data/kaliningrad/kaliningrad.xml").open() as f:
print(f)
...gives...
File System Encoding: utf-8
Preferred encoding: cp1252
<_io.TextIOWrapper name='data\\kaliningrad\\kaliningrad.xml' mode='r' encoding='cp1252'>
which is clerly the source of our problem!
This error came up as part of a practical for a course at the University of Manchester - we have been running it for years and this is the first time that this has happened, I am not sure what has changed to cause it (we are seeing it across all Windows machines that we have tried, not just a particular build etc.). I guess that this sort of thing might be part of the motivation behind PEP686, which sems to suggest that Python will override the locale settings to UTF-8 by default from version 3.15.
Nevertheless, adding an encoding
argument to the function as you have seems like an ideal solution - thanks for dealing with it so quickly.
from osmnx.
Great, I'll merge that PR and dream of the day when Python 3.15 arrives 🥳
from osmnx.
Related Issues (20)
- Removal of inner_polygons from outer_polygons (creation of holes), creates maximum one hole. HOT 5
- Include parking space data in nodes HOT 7
- Fill missing values with most common value on similar roads HOT 4
- OSMnx 2.0 Migration Guide HOT 5
- Add junction/intersection types to nodes HOT 6
- Support directed bearing/orientation distributions and plots HOT 5
- Support loading and/or merging multiple networks HOT 5
- [Meta] Enable Discussions tab on this GitHub repo HOT 1
- Further API streamlining for v2 HOT 2
- _bearings_distribution: apply weight during histogram HOT 2
- Conditional tolerance for intersection consolidation HOT 16
- Add edge_attrs_differ argument to each graph.graph_from_* method HOT 2
- Add support for implicit maxspeed values
- `ox.shortest_path` returns `None` HOT 3
- Add function to merge parallel roads HOT 3
- Publish v2 pre-releases HOT 1
- Issues with plotting and basic stats when using DiGraphs HOT 1
- AttributeError: module 'osmnx' has no attribute 'convert' HOT 1
- InsufficientResponseError while HOT 1
- FutureWarning: The 'unary_union' attribute is deprecated HOT 4
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 osmnx.