[NGA程序员多]几年前让一个朋友帮忙写了一个python的程序,现在换了一台电脑,怎么都运行不了,求助!

kalechips-avatar

kalechips

2021-07-16T08:06:58+00:00

当时还在NGA发过贴,就是想编一个小程序,pc上运行的,有一个带国家边境的那种空白的世界地图,随机把一个国家标红,然后下面一个输入框输入这个国家的名称
然后一个按钮验证答案,另外一个按钮下一题
当时NGA有个热心大佬指导我一步步的编,大概写了一半代码以后,大佬干脆直接自己帮我写完了。。。一共100多行的代码,效果非常满意,完全能实现我的需求

最近换了个单位,单位发了新电脑,我想说在新电脑上也复制一个,但是安装了python,安装了anaconda,把需要的那些包都一个个的下载好了,就是运行不了
有大佬帮忙看看是什么原因吗?
错误代码是这样的
[img]https://img.nga.178.com/attachments/mon_202107/23/-7Q2o-jz4bZdT3cSsg-ee.jpg[/img]

程序源代码在第二个附件,后缀名改成zip就行,里面那个guess_country1
briel (his)-avatar

briel (his)

emmm,python的版本和之前的一样吗
WORD_FPS-avatar

WORD_FPS

ax.add_geometry(geo,...
改成ax.add_geometry([geo],..试试?
感觉是引用的包升级参数类型变了
Haforshort-avatar

Haforshort

这种主要看python和插件版本。
python各个版本插件支持挺复杂的。
这种最好备份自己的python文件夹好一点
kalechips-avatar

kalechips

[quote][pid=534829652,27732945,1]Reply[/pid] Post by [uid=37710494]zhjqi111[/uid] (2021-07-23 16:37):

emmm,python的版本和之前的一样吗[/quote]好像一个是3.4,最新这个装的是3.8
memelord9-avatar

memelord9

show you the code:
if geo.geom_type=='MultiPolygon':
ax.add_geometries(geo, ccrs.PlateCarree(), facecolor=cfeature.COLORS['land'], edgecolor='grey')
elif geo.geom_type=='Polygon':
ax.add_geometries([geo], ccrs.PlateCarree(), facecolor=cfeature.COLORS['land'], edgecolor='grey')

把第50行 改成这样就好了,拷贝的时候 注意缩进
CaramelDinosaur-avatar

CaramelDinosaur

[quote][pid=534992337,27732945,1]Reply[/pid] Post by [uid=698096]bobay[/uid] (2021-07-24 09:27):
show you the code:
if geo.geom_type=='MultiPolygon':
ax.add_geometries(g......[/quote]老哥强呀!
memelord9-avatar

memelord9

Reply to [pid=534992337,27732945,1]Reply[/pid] Post by [uid=698096]bobay[/uid] (2021-07-24 09:27)

下面这个也要判断下,不然也报错,代码如下:
if geos[choosen_id].geom_type=='MultiPolygon':
choosen_fig = ax.add_geometries(geos[choosen_id], ccrs.PlateCarree(), facecolor='red', edgecolor='grey')
elif geos[choosen_id].geom_type=='Polygon':
choosen_fig = ax.add_geometries([geos[choosen_id]], ccrs.PlateCarree(), facecolor='red', edgecolor='grey')
memelord9-avatar

memelord9

改动比较多,然后发私信没有缩进,直接整理估计要半天,还是发附件算了
[img]https://img.nga.178.com/attachments/mon_202107/24/-7Q2o-5uuuK2.jpg[/img]
Spacewaifu-avatar

Spacewaifu

写的的程序不封包吗?
l_i_l_element-avatar

l_i_l_element

好像是我教你兄弟,你是不是搞完了还给我发了个红包,我记得你朋友圈儿女双全人生赢家
memelord9-avatar

memelord9

Reply to [pid=535066253,27732945,1]Reply[/pid] Post by [uid=62723879]好看的伪娘请对号入座[/uid] (2021-07-24 15:07)
链接:[url]https://pan.baidu.com/s/1h1WwzPdRRfKZbo4gC8Ebqw[/url]
提取码:09sj
简单封了个,win10下可以运行,win7我试了下不可以