【发布时间】:2013-02-10 08:15:06
【问题描述】:
我用 Eclipse 用 Python 编写了一个小脚本,它在 Eclipse 中执行时可以工作。但它不适用于命令行:
>python test.py argument1 argument2
from src import Tests, ImportError: No module named src
脚本存储在以下文件夹中:
ScriptFolder
.input
.report
.src
..test.py
..Tests
...Test1.py
...Test2.py
..TestUtils
...FileUtils.py
这就是我在 test.py 中进行导入的方式:
from src import Tests
from TestUtils import FileUtils
关于init.py文件,与test.py共享文件夹的是空的,进入Tests文件夹的有这样的内容:
import Test1
import Test2
而TestUtils中的init.py文件有这样的内容:
import FileUtils
问题是,如果我将行 from src import Tests 更改为只是 import Tests 我在 Eclipse 中遇到错误:Unresolved imports: Tests. found at src.Tests
如何使它同时适用于 Eclipse 和命令行?
【问题讨论】:
标签: python eclipse command-line import pydev