问题描述
我有一个名为boo
的软件包,它是从github存储库安装在google colab上的.安装过程看起来很好,并显示成功消息Successfully installed boo-0.1
.但是,import boo
在首次内部导入时失败.
I have a package called boo
which I install on google colab from a github repository. The installation process looks fine and results in success message Successfully installed boo-0.1
. However import boo
fails on first internal import.
我在本地虚拟环境中复制了相同的安装步骤,并且程序包正常工作,但在collab上却没有.
I replicated the same installation steps in a local virtual environment and package worked, but not on collab.
这是我的步骤和错误跟踪:
Here are my steps and error trace:
!rm -rf sandbox
!git clone https://github.com/ru-corporate/sandbox.git
!pip install -r sandbox/requirements.txt
!pip install sandbox/.
或者,我尝试了
!pip install git+https://github.com/ru-corporate/sandbox.git@master
错误跟踪是:
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-7-fc0b1d036b35> in <module>()
----> 1 import boo
/usr/local/lib/python3.6/dist-packages/boo/__init__.py in <module>()
----> 1 from boo.boo import download, build, read_dataframe, files
2 from boo.views.whatis import whatis
/usr/local/lib/python3.6/dist-packages/boo/boo.py in <module>()
3 from tqdm import tqdm
4
----> 5 from boo.file.download import curl
基本上,从根目录__init__.py
导入到根目录boo.py
并偶然发现boo/file/download.py
.
Basically, from root __init__.py
the import goes to root boo.py
and stumbles upon finding boo/file/download.py
.
我如何使该软件包在协作上正常工作?
How do I make this package work on collab?
推荐答案
我可以按照建议这里:
# ...
packages=setuptools.find_packages()
# ...
与本地安装相比,Somehow Colab在此参数上的限制更大.
Somehow Colab is more restrictive on this parameter than local installation.
这篇关于子模块导入不适用于Google Colab的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!