|-content
|-utils
|- parse_config.py
|-models.py
folder structure 这是我在 google colab 中的文件夹结构。
我已经安装了 Pytorch 以及该项目的所有其他要求。 这里的 models.py 文件无法访问 utils 文件夹中的文件。
在我的 models.py
中,我正在导入位于 utils 文件夹内的 utils.parse_config
,但它显示以下错误。
ImportErrorTraceback (most recent call last) <ipython-input-6-77f4a3369184> in <module>()
----> 1 from models import *
2 from utils import *
3
4 import os, sys, time, datetime, random
5 import torch
/content/models.py in <module>()
9 from PIL import Image
10
---> 11 from utils.parse_config import *
12 from utils.utils import build_targets
13 from collections import defaultdict
ImportError: No module named utils.parse_config
--------------------------------------------------------------------------- NOTE: If your import is failing due to a missing package, you can manually install dependencies using either !pip or !apt.
To view examples of installing some common dependencies, click the "Open Examples" button below.
---------------------------------------------------------------------------
如何让 models.py 访问 utils 文件夹中的文件?
最佳答案
Models.py 似乎不在 utils 文件夹中。请重新检查
关于python - .py 不从内容文件夹中读取,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55129148/