给定以下 python 项目,在 PyDev 中创建:
├── algorithms
│ ├── __init__.py
│ └── neighborhood
│ ├── __init__.py
│ ├── neighbor
│ │ ├── connector.py
│ │ ├── __init__.py
│ │ ├── manager.py
│ │ └── references.py
│ ├── neighborhood.py
│ ├── tests
│ │ ├── fixtures
│ │ │ └── neighborhood
│ │ ├── __init__.py
│ └── web
│ ├── __init__.py
│ └── service.py
├── configuration
│ ├── Config.py
│ └── __init__.py
├── __init__.py
└── webtrack
|- teste.py
├── .gitignore
├── __init__.py
├── manager
├── Data.py
├── ImportFile.py
└── __init__.py
我们一直在尝试将模块从一个文件夹导入另一个文件夹,但没有成功,例如:
from algorithms.neighborhood.neighbor.connector import NeighborhoodConnector
产生结果:
Traceback (most recent call last):
File "teste.py", line 49, in <module>
from algorithms.neighborhood.neighbor.connector import NeighborhoodConnector
ImportError: No module named algorithms.neighborhood.neighbor.connector
我们尝试将其路径附加到 sys.path 变量,但没有成功。
我们还尝试使用 os.walk 将所有路径插入到 PATH 变量中,但仍然得到相同的错误,即使我们检查了 PATH 确实包含查找模块的路径。
我们在 Linux Ubuntu 13.10 上使用 Python 2.7。
我们有什么可能做错的吗?
提前致谢,