ModuleNotFoundError: No module named 'pyproj.crs.crs'; 'pyproj.crs' is not a package

ModuleNotFoundError: No module named 'pyproj.crs.crs'; 'pyproj.crs' is not a package

我正在尝试使用 nx.read_gpickle 将 networkx 图形对象导入为 pickle,但收到 pyproj.crs 包不存在的错误。请注意,我正在使用 GOSTnets,这是一个使用 networkx、geopandas、osmnx 和 peartree 为网络分析开发的软件包。

我首先构建了图形,然后使用 osmnx.project_graph 投影并使用 GOSTnets.save 保存:

G_proj = ox.project_graph(G)

# save Graph as pickle using GOSTnets.save:
gn.save(G_proj,'processed_graph_cleaned_part1_proj','./', pickle = True, edges = False, nodes = False)

# save in networkx terms:
wpath = r"MYPATH"
savename = 'processed_graph_cleaned_part1_proj'
nx.write_gpickle(G, os.path.join(wpath, '%s.pickle' % savename))

然后在另一个笔记本中,我尝试导入图表:

import os, sys, time, importlib

import geopandas as gpd
import pandas as pd
import networkx as nx
import numpy as np
import GOSTnets as gn

# make sure osmium is installed (pip install osmium)
# An internal function called when creating the OSM_to_Network object will import osmium
from shapely.geometry import LineString, Point
import osmnx as ox

# import Graph pickle
G = nx.read_gpickle(r"MYPATH\processed_graph_cleaned_part1_proj.pickle")

这样做时,我收到以下错误:

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-19-2be4f8fabb58> in <module>
      1 # read graph
      2 # this graph is the
----> 3 G = nx.read_gpickle(r"MYPATH\processed_graph_cleaned_proj.pickle")

<decorator-gen-748> in read_gpickle(path)

C:\WBG\Anaconda\envs\test_gostNets\lib\site-packages\networkx\utils\decorators.py in _open_file(func_to_be_decorated, *args, **kwargs)
    238         # Finally, we call the original function, making sure to close the fobj
    239         try:
--> 240             result = func_to_be_decorated(*new_args, **kwargs)
    241         finally:
    242             if close_fobj:

C:\WBG\Anaconda\envs\test_gostNets\lib\site-packages\networkx\readwrite\gpickle.py in read_gpickle(path)
     99     .. [1] https://docs.python.org/2/library/pickle.html
    100     """
--> 101     return pickle.load(path)
    102 
    103 

ModuleNotFoundError: No module named 'pyproj.crs.crs'; 'pyproj.crs' is not a package

我有 pyproj 版本:2.4.2.post1,构建:py36hc1560cf_1。 Networkx 版本:2.4。 运行 jupyter 中的 conda。有谁知道发生了什么事?如果问题重复,我们深表歉意。

您使用的是过时版本的 pyproj。例如,当前版本的 OSMnx requires pyproj>=2.6. Version 2.4 does not have the CRS module you are trying to use. Make sure you install OSMnx according to its installation instructions.

这类似于此处回答的问题:Cannot import name 'CRS' from 'pyproj' for using the osmnx library