As a part of a program, I have to read a graph from a pickle file and then return it as a graph. I must say I'm using OSMnx and networkx to do so.
I already have this pickle file containing a graph downloaded from OSMnx. But as I call the function it raises an error.
Code:
import networkx
import osmnx as ox
import requests
import matplotlib.cm as cm
import matplotlib.colors as colors
import pickle
ox.config(use_cache=True, log_console=True)
ox.__version__
def load_graph(filename):
"""Uploads a graph from a pickle file and it returns it"""
infile = open(filename, 'rb')
G = pickle.load(infile)
infile.close()
return G
def main():
ox.plot_graph(load_graph("graph1.pickle"))
main()
Error:
AttributeError: 'str' object has no attribute 'nodes'
What should I do?