导入问题,__init__.py 与 .ipynb
我是一个初学者,在Python中正确组织了我的代码,我正在努力从.py
script中的Main .ipynb
中进行进口。
我的文件夹是按照以下方式组织的:
| naive.ipynb
| requirements.txt
|
+---data
| DNA_train.txt
| pseudomona.feather
| pseudo_test.csv
| pseudo_train.csv
|
+---model
| dna_token.model
|
\---src
token_dna_converter.py
__init__.py
正如我所阅读的,为了能够从其他文件夹导入类,我应该添加__ INT __。py
文件以从超级文件夹访问。在__ INIT __。py
中,我
在.token_dna_converter导入tokendna 之后列出以下内容:
之后,我想在笔记本中调用此脚本,我尝试了以下内容:
>从token_dna_converter导入tokendna
但是,.ipynb无法检测到此内部“软件包” ... 我不知道为什么,我正在努力尝试解决这个问题。
有人知道我应该如何正确地调用此脚本吗?我会感谢一切!
I'm a beginner organizing my code properly in python and I am struggling a bit doing imports in my main .ipynb
from a .py
script.
My folder is organized as it follows:
| naive.ipynb
| requirements.txt
|
+---data
| DNA_train.txt
| pseudomona.feather
| pseudo_test.csv
| pseudo_train.csv
|
+---model
| dna_token.model
|
\---src
token_dna_converter.py
__init__.py
As I have read, to be able to import classes from a different folder, I should add a __init__.py
file to able access from a super folder. In the __init__.py
I put the following:
from .token_dna_converter import tokenDNA
Afterwards, I want to call this script in a notebook and I have tried the following:
from token_dna_converter import tokenDNA
However, the .ipynb does not detect this inner "package"...
I don't know why and I am struggling to try to fix this.
Does anyone know how should I properly call this script? I would appreciate everything!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论