在test.py中,我试图导入test_data:
import unittest2
import re
from test_data import receipt1_example
Run Code Online (Sandbox Code Playgroud)
test_data.py与test.py位于同一目录中.我收到以下错误:
/Users/ahammond/.virtualenvs/ric2.6/bin/python2.6 /Applications/PyCharm.app/helpers/pycharm/utrunner.py /Users/ahammond/src/hackfest_spring_2012/parse_me/test.py::test true Testing上午11:30开始... Traceback(最近一次调用最后一次):
文件"/Applications/PyCharm.app/helpers/pycharm/utrunner.py",第121行,在module = loadSource(a [0])文件中/Applications/PyCharm.app/helpers/pycharm/utrunner.py",第44行,在loadSource模块中= imp.load_source(moduleName,fileName)文件"/Users/ahammond/src/hackfest_spring_2012/parse_me/test.py",行4,从test_data导入receipt1_example ImportError:没有名为test_data的模块进程以退出代码1结束
如您所见,我使用virtualenv在pycharm下运行它.这是配置的屏幕截图:

到目前为止,我的代码正在执行以下操作.我想摆脱subprocess.call()的东西
import git
from subprocess import call
repo = git.Repo(repo_path)
repo.remotes.origin.fetch(prune=True)
repo.head.reset(commit='origin/master', index=True, working_tree=True)
# I don't know how to do this using GitPython yet.
os.chdir(repo_path)
call(['git', 'submodule', 'update', '--init'])
Run Code Online (Sandbox Code Playgroud)