Jupyter Lab 上的 OSMnx - 生成地图时遇到问题

时间:2021-05-01 12:41:15

标签: jupyter-notebook osmnx

这里是 Python 菜鸟。

我正在关注此 guide 以开始使用 OSMnx 和 Python。在第 3 步中,打开 jupyter lab 并运行下面的代码后

%matplotlib inline 
G = ox.graph_from_place('Piedmont, California, USA', network_type='drive')
fig, ax = ox.plot_graph(ox.project_graph(G))

我收到以下错误。我在 Mac 和 Windows 上都遇到了同样的错误,即无法从 'fractions' 导入 'gcd'。

*ImportError*     Traceback (most recent call last)
<ipython-input-1-ef975266b8c0> in <module>
----> 1 import osmnx as ox
      2 get_ipython().run_line_magic('matplotlib', 'inline')
      3 G = ox.graph_from_place('Piedmont, California, USA', network_type='drive')
      4 fig, ax = ox.plot_graph(ox.project_graph(G))

~\anaconda\envs\ox\lib\site-packages\osmnx\__init__.py in <module>
      1 """OSMnx init."""
      2 
----> 3 from ._api import *
      4 from ._version import __version__

~\anaconda\envs\ox\lib\site-packages\osmnx\_api.py in <module>
      2 
      3 from .bearing import add_edge_bearings
----> 4 from .distance import get_nearest_edge
      5 from .distance import get_nearest_edges
      6 from .distance import get_nearest_node

~\anaconda\envs\ox\lib\site-packages\osmnx\distance.py in <module>
      3 import itertools
      4 
----> 5 import networkx as nx
      6 import numpy as np
      7 import pandas as pd

~\anaconda\envs\ox\lib\site-packages\networkx\__init__.py in <module>
    112 from networkx.relabel import *
    113 
--> 114 import networkx.generators
    115 from networkx.generators import *
    116 

~\anaconda\envs\ox\lib\site-packages\networkx\generators\__init__.py in <module>
     12 from networkx.generators.expanders import *
     13 from networkx.generators.geometric import *
---> 14 from networkx.generators.intersection import *
     15 from networkx.generators.joint_degree_seq import *
     16 from networkx.generators.lattice import *

~\anaconda\envs\ox\lib\site-packages\networkx\generators\intersection.py in <module>
     11 import random
     12 import networkx as nx
---> 13 from networkx.algorithms import bipartite
     14 from networkx.utils import py_random_state
     15 

~\anaconda\envs\ox\lib\site-packages\networkx\algorithms\__init__.py in <module>
     14 from networkx.algorithms.cycles import *
     15 from networkx.algorithms.cuts import *
---> 16 from networkx.algorithms.dag import *
     17 from networkx.algorithms.distance_measures import *
     18 from networkx.algorithms.distance_regular import *

~\anaconda\envs\ox\lib\site-packages\networkx\algorithms\dag.py in <module>
     21 
     22 from collections import defaultdict, deque
---> 23 from fractions import gcd
     24 from functools import partial
     25 from itertools import chain

ImportError: cannot import name 'gcd' from 'fractions' (C:\Users\anaconda\envs\ox\lib\fractions.py)```

0 个答案:

没有答案