模块 'geopandas' 没有属性 'read_file'
Module 'geopandas' has no attribute 'read_file'
我正在尝试像这样在 geopandas 中打开一个形状文件:
import geopandas as gpd
shp = gpd.read_file("C:\my_file.shp")
但是这个returns错误:
Traceback (most recent call last):
File "<ipython-input-5-d0665b3cc874>", line 3, in <module>
shp = gpd.read_file("C:\my_file.shp")
AttributeError: module 'geopandas' has no attribute 'read_file'
我也试过这样做:
from geopandas import GeoSeries, GeoDataFrame
哪个returns:
Traceback (most recent call last):
File "<ipython-input-6-338cbf14bf64>", line 1, in <module>
from geopandas import GeoSeries, GeoDataFrame
File "C:\Users\spotter\Documents\Python_Scripts\geopandas.py", line 1, in <module>
from geopandas import GeoSeries, GeoDataFrame
ImportError: cannot import name 'GeoSeries'
我正在使用 anaconda3-5.0.1 并使用 conda install -c conda-forge geopandas
安装了 geopandas
编辑:
我刚刚下载了 anaconda2,geopandas 工作正常,所以这与 anaconda3 有关
您不应将文件名命名为 geopandas.py。从 from geopandas import GeoSeries, GeoDataFrame
的回溯中,我们可以知道您使用的文件名是 geopandas.py 并且它使得 Python 导入此文件而不是 geopandas
模块。将以下路径中的此文件更改为其他名称,它应该可以工作。
from geopandas import GeoSeries, GeoDataFrame
File "C:\Users\XXXXX\Documents\Python_Scripts\geopandas.py", line 1, in <module>
---------------
我正在尝试像这样在 geopandas 中打开一个形状文件:
import geopandas as gpd
shp = gpd.read_file("C:\my_file.shp")
但是这个returns错误:
Traceback (most recent call last):
File "<ipython-input-5-d0665b3cc874>", line 3, in <module>
shp = gpd.read_file("C:\my_file.shp")
AttributeError: module 'geopandas' has no attribute 'read_file'
我也试过这样做:
from geopandas import GeoSeries, GeoDataFrame
哪个returns:
Traceback (most recent call last):
File "<ipython-input-6-338cbf14bf64>", line 1, in <module>
from geopandas import GeoSeries, GeoDataFrame
File "C:\Users\spotter\Documents\Python_Scripts\geopandas.py", line 1, in <module>
from geopandas import GeoSeries, GeoDataFrame
ImportError: cannot import name 'GeoSeries'
我正在使用 anaconda3-5.0.1 并使用 conda install -c conda-forge geopandas
编辑:
我刚刚下载了 anaconda2,geopandas 工作正常,所以这与 anaconda3 有关
您不应将文件名命名为 geopandas.py。从 from geopandas import GeoSeries, GeoDataFrame
的回溯中,我们可以知道您使用的文件名是 geopandas.py 并且它使得 Python 导入此文件而不是 geopandas
模块。将以下路径中的此文件更改为其他名称,它应该可以工作。
from geopandas import GeoSeries, GeoDataFrame
File "C:\Users\XXXXX\Documents\Python_Scripts\geopandas.py", line 1, in <module>
---------------