简体   繁体   English

upload.gpx 文件 Streamlit Python

[英]upload .gpx file Streamlit Python

I've made a Streamlit app using python, in which it is possible to drag and drop a gpx file.我使用 python 制作了一个 Streamlit 应用程序,可以在其中拖放 gpx 文件。

import streamlit as st 
file = st.file_uploader("Upload a strava file (gpx)", type=["gpx"],accept_multiple_files=False)

在此处输入图像描述

However opening the InMemoryUploadedFile with the package gpxpy package isn't possible.但是,无法使用 package gpxpy package 打开 InMemoryUploadedFile。 Giving me a KeyError: 3655给我一个 KeyError:3655

import gpxpy
gpx = gpxpy.parse(file)

Can someone help me?有人能帮我吗?

Please try:请试试:

import streamlit as st
import gpxpy

file = st.file_uploader("Upload a strava file (gpx)", type=["gpx"], accept_multiple_files=False)

if uploaded_file is not None:
    gpx = gpxpy.parse(uploaded_file)

Please also make sure both streamlit and gpxpy is updated to the latest version and the gpx file is not corrupted还请确保 streamlit 和 gpxpy 都更新到最新版本并且 gpx 文件没有损坏

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM