简体   繁体   English

在Google协作平台上使用自定义程序包

[英]Using custom packages on Google-Colaboratory

I'm trying to use my custom package on Google Colaboratory and I'm facing some weird errors while doing that. 我正在尝试在Google Colaboratory上使用我的自定义程序包,而这样做时遇到了一些奇怪的错误。 Note that the package I'm trying to use works without any error on my computer/s. 请注意,我尝试使用的软件包在我的计算机上没有任何错误。

It is a Python 3.6 package called rohan . 这是一个名为rohan的Python 3.6软件包。 It is very basic in terms of functionalities. 就功能而言,这是非常基本的。

At first I installed it through pip command ( pip install rohan ). 首先,我通过pip命令安装了它( pip install rohan )。 But I got a ModuleNotFoundError error. 但是我收到了ModuleNotFoundError错误。

import rohan
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-9046ed7b4857> in <module>()
----> 1 import rohan

ModuleNotFoundError: No module named 'rohan'

Then I installed it from the source. 然后我从源代码安装了它。

%%bash
git clone https://github.com/rraadd88/rohan.git
cd rohan
pip install -e .

This time, I could import the main module without any error ( import rohan ). 这次,我可以导入主模块而没有任何错误( import rohan )。 However if I try to import submodule ( dandage ), I get an ImportError . 但是,如果我尝试导入子模块( dandage ), dandage收到ImportError

from rohan import dandage
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-5-6ea35256170e> in <module>()
----> 1 from rohan import dandage

ImportError: cannot import name 'dandage'

To me, the structure of the the package looks ok. 对我来说,包装的结构看起来还不错。

rohan
├── MANIFEST.in
├── rohan
│   ├── dandage
│   │   ├── subsubmodule
│   │   │   ├── script.py
│   │   │   └── __init__.py
|   |   ├── script.py
|   |   └── __init__.py
|   ├── script.py
│   └── __init__.py
├── setup.cfg
└── setup.py

Source: https://github.com/rraadd88/rohan 资料来源: https : //github.com/rraadd88/rohan

Also as I said, the package works very well on my computer/s. 就像我说的那样,该软件包在我的计算机上也能很好地工作。 So I'm not sure why I'm not able to use it on Colaboratory. 所以我不确定为什么不能在Colaboratory上使用它。

You'll need to add the directory where you cloned the repo to sys.path . 您需要将克隆存储库的目录添加到sys.path For example: 例如:

!git clone https://github.com/rraadd88/rohan.git
import sys
sys.path.append('/content/rohan')
from rohan import dandage

Here's a complete notebook: https://colab.research.google.com/drive/1LSC_HyfbuOlEn7pfZYAjiOSE1fp6uipl 这是完整的笔记本: https : //colab.research.google.com/drive/1LSC_HyfbuOlEn7pfZYAjiOSE1fp6uipl

when i use autokeras,i also meet the same problem: 当我使用autokeras时,我也遇到同样的问题:

ModuleNotFoundError Traceback (most recent call last) in () ----> 1 from autokeras.text.text_supervised import TextClassifier 在()----> 1中从autokeras.text.text_supervised import TextClassifier中的ModuleNotFoundError Traceback(最近一次调用最后一次)

ModuleNotFoundError: No module named 'autokeras.text' ModuleNotFoundError:没有名为“ autokeras.text”的模块


NOTE: If your import is failing due to a missing package, you can manually install dependencies using either !pip or !apt. 注意:如果由于缺少软件包而导致导入失败,则可以使用!pip或!apt手动安装依赖项。

To view examples of installing some common dependencies, click the 要查看安装一些常见依赖项的示例,请单击

"Open Examples" button below. 下面的“打开示例”按钮。

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

相关问题 使用google-colaboratory上传到google驱动器的文件的路径是什么? - What is the path of the file uploaded to google drive using google-colaboratory? 使用Google-colaboratory时如何在wordcloud中设置font_path? - How to set the font_path in wordcloud while using Google-colaboratory? 无法从 google-colaboratory 打开 google-storage 中的文件 - Unable to open file in google-storage from google-colaboratory 当尝试SVD时,Google-colaboratory内核会死掉 - Google-colaboratory kernel dies when SVD is attempted 如何在google-colaboratory上安装需要编译的库 - How to install libraries that require compilation on google-colaboratory 如何使用命令行 arguments 在 google-colaboratory 中运行 python 文件? - How to run python file in google-colaboratory with comand line arguments? 一次下载google colaboratory中的所有nltk包 - Download all nltk packages in google colaboratory at once 有什么方法可以运行 R 代码的另一个单元格,它取决于当前 python flask 用户在 google-colaboratory 中输入的应用程序单元格? - Is there any way to run another cell of R code which depends on current python flask app cell's input by user in google-colaboratory? 使用本地 GPU 的 Google Colaboratory 本地运行时 - Google Colaboratory local runtime using local GPU 在Google Colaboratory上使用带有Tensorflow Eager执行的GPU - Using a GPU with Tensorflow Eager Execution on Google Colaboratory
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM