我无法将文件上传到Google Colab上的Jupyter Notebook

时间:2019-06-03 19:54:51

标签: python jupyter-notebook google-colaboratory

在左侧的“文件”选项卡上,单击“上传”按钮以上传名为titanic_train.csv的文件。但是,该图像会转到“文件”标签的底部,并且仅停留在该位置,而我的程序再也无法访问该图像了,

titanic_train.png never uploads

作为一种解决方法,我还尝试了通过Google Colab的内置google.colab.files.upload方法进行上传,该方法成功提示我输入文件,但是在消息中的上传速度为0%时停滞了。

titanic_train.csv(text/csv) - 72499 bytes, last modified: 9/20/2018 - 0% done

Viz,

The upload stalls at 0 percent

有人知道我可能做错了什么,或者如何解决这个问题,以便我的程序可以通过Google Colab成功访问文件?

我正在Ubuntu 16.04上使用Chrome进行此操作。

2 个答案:

答案 0 :(得分:0)

在尝试上传时使用野生动物园引起了一些问题,您尝试过Chrome吗?那对我有用。另外,请尝试使用此代码上传。该文件还可以保存文件,因此您不必每12小时上传一次。

import React from 'react';
import { Button, View, Text } from 'react-native';
import { createStackNavigator, createAppContainer } from 'react-navigation';

class HomeScreen extends React.Component {
  state = { value: 10 }
  render() {
    const { screenProps } = this.props;
    return (
      <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
        <Text>Home Screen</Text>
        <Button
          title="Click"
          onPress={() => {
            this.props.navigation.navigate('Detail'); // no navigation prop
            setTimeout(() => {
              screenProps.updateValue(screenProps.appState.value + 1) // updating state of App rather than state of Home
            }, 1000);
          }}
        />
      </View>
    );
  }
}

class DetailScreen extends React.Component {
  render() {
    const { screenProps } = this.props;
    return (
      <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
        <Text>Detail Screen</Text>
        <Text>{screenProps.appState.value}</Text>
      </View>
    );
  }
}

const RootStack = createStackNavigator(
  {
    Home: HomeScreen,
    Detail: DetailScreen,
  },
  {
    initialRouteName: 'Home',
  }
);

const AppContainer = createAppContainer(RootStack);

export default class App extends React.Component {

  state = {value: 10} // state in App now instead of Home

  updateValue = (value) => { // method to update App's state, passed to children
    this.setState({value})
  }

  render() {
    return <AppContainer screenProps={{
      appState: this.state,
      updateValue: this.updateValue
    }}/>;
  }

}

答案 1 :(得分:0)

问题出在我的文件上。这是我从Kaggle下载的著名的《泰坦尼克号幸存者》数据集。该文件具有“禁止读取,禁止写入,禁止执行”的权限:

me@fakehost:~/titanic-dataset$ ls -l
total 116
---------- 1 hc-16 hc-16  2843 sep 20  2018 gender_baseline.csv
---------- 1 hc-16 hc-16 39299 sep 20  2018 titanic_test.csv
---------- 1 hc-16 hc-16 72499 sep 20  2018 titanic_train.csv

Chrome无法上传文件,因为该文件没有读取权限,因此已被固定为chmod 400 *

极大的放心,我无法想象为什么Kaggle授予这些文件000的权限。