【colaboratory】ModuleNotFoundError: No module named 'forward'
在colaboratory中,import 自己写的 py 文件往往会爆出 ModuleNotFoundError: No module named ‘forward' 的错误。
就其原因,是由于 Drive 中文件布局与 Colab 中文件布局是不同的。
如果要在 Colab 中使用 Drive 文件,则需要运行下段代码段,在 Colab 后端安装到你的云端硬盘
from google.colab import drive
drive.mount('/content/drive')
运行

下一步将工作目录更改为Drive根目录。
%cd /content/drive/My\ Drive # List files to make sure we're in the expected directory. # Your output will look different, showing your own Drive files here. !ls
运行

我需要加载的 forward.py 文件在 Colab Notebooks 文件夹中,所以代码为
%cd /content/drive/My\ Drive/Colab\ Notebooks # List files to make sure we're in the expected directory. # Your output will look different, showing your own Drive files here. !ls
此时我们就可以 import forward 文件
import forward
运行就不会报错了。
但是当将 import forward 语句放在其他 import 后面时,依然会出现相同的报错情况,但将其放在第一个位置时,就不会报错。
参考:
Neural Networks with Google CoLaboratory | Artificial Intelligence Getting started
【colaboratory】ModuleNotFoundError: No module named 'forward'的更多相关文章
- 【Django】ModuleNotFoundError: No module named 'books_ordersschool'
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x00000 ...
- 【转】modulenotfounderror: no module named 'matplotlib._path'问题的解决
今天在装matplotlib包的时候遇到这样的问题,在网上找了很长时间没有类似很好的解决方法,最后自己 研究找到了解决的方法. 之前在pycharm里面已经装了matplotlib包,之后觉着下载包挺 ...
- 【Python】ModuleNotFoundError: No module named 'matplotlib.pyplot'
安装好matplotlib后,很激动的建立了一个文件夹matplotlib,并且在其下面建立了,mpl_squraes.py文件,代码编辑完成以后,点击运行,报错如下: 仔细分析了之后,发现是文件夹名 ...
- 【AI-人工智能-mmdetection】ModuleNotFoundError: No module named 'mmdet.version'
在集成 mmdetection 框架时遇到这样的问题. ModuleNotFoundError: No module named 'mmdet.version' mmdetection 框架搭建过程很 ...
- 【Linux】`ImportError: No module named '_tkinter'
在centos7 系统下,导入matplotlib时,出现ImportError: No module named '_tkinter'的错误 首先使用以下命令查看模块是否存在 yum list in ...
- 【python】解决No module named _sqlite3的问题
环境版本说明: centos 7 python3.6.4 django 2.0 在创建django项目时候.报错以下信息 详细错误信息如下: 原因: 未安装sqlite 模块 解决: 1 安装 sql ...
- error: ModuleNotFoundError: No module named 'ConfigParser'
(env2.7) Kaitlyns-Mac:bin kaitlyn$ pip install MySQL-python Looking in indexes: https://pypi.tuna.ts ...
- python3 使用flask连接数据库出现“ModuleNotFoundError: No module named 'MySQLdb'”
本文链接:https://blog.csdn.net/Granery/article/details/89787348 在使用python3连接MySQL的时候出现了 ‘ModuleNotFoundE ...
- 从git上pull下的代码,执行时提示:ModuleNotFoundError: No module named '......',解决方法如下:
方法一: 如果没有安装,如下: 1.PyCharm : file-> setting->Project interpreter–>package2.右侧有个+ 点击3.进入后 搜索p ...
随机推荐
- cocos2d-x3.0 XML解析
在2dx3.0中xml解析已经不用自己找库了.已经为我们集成好了. text.xml <?xml version ="1.0" encoding ="UTF8&qu ...
- GPUImage API 文档之GPUImageFilter类
GPUImageFilter类 方法 - (id)initWithVertexShaderFromString:(NSString *)vertexShaderString fragmentShade ...
- 【python】理想论坛爬虫1.08
#------------------------------------------------------------------------------------ # 理想论坛爬虫1.08, ...
- ListView显示不同布局
在使用不同布局的时候,getItemViewType和getViewType不能少,通常是不用这两个函数的重载的 listView.setAdapter(new BaseAdapter() { @Ov ...
- Java 判断Windows下某个进程是否运行
public static void main(String[] args) { String keyWord = "chrome.exe"; Runtime runtime = ...
- 获取请求真实ip
/** * Copyright (c) 2011-2014, James Zhan 詹波 (jfinal@126.com). * * Licensed under the Apache License ...
- Linux安装和设置Samba服务器
1. 安装 安装前先关闭iptables和SELinux. Centos输入以下命令: yum install samba samba-client Ubuntu输入以下命令: apt-get ins ...
- Windows Python+Eclipse环境配置
参考这几篇博客: 1:http://www.cnblogs.com/realh/archive/2010/10/04/1841907.html 2:http://www.cnblogs.com/min ...
- Android——代码中使用颜色值
android中设置颜色时,可以直接使用颜色值来设置: view.setBackgroundColor(Color.parseColor("#颜色值"));
- Linux安装nginx并设置https(openssl
一.安装依赖包 1.$sudo apt-get install openssl 或者$sudo apt-get install libssl-dev 2.$sudo apt-get instal ...