1

I get this error when loading a file using cPickle.

Directory tree:

/qanta/preprocess/dparse_to_dtree.py
/qanta/qanta.py
/qanta/util/dtree_util.py
main.py
extract_data.py

main.py imports extract_data.py

extract_data.py imports dparse_to_dtree.py

A function in dparse_to_dtree.py cPickle dumps a dtree object which is defined in dtree_util.py

then from Main.py a subprocess calls qanta.py to execute but there I get the error:

Traceback (most recent call last):
File "qanta/qanta.py", line 142, in <module>
cPickle.load(open(args['data'], 'rb'))
ImportError: No module named util.dtree_util

What is going wrong here?

KameeCoding
  • 693
  • 2
  • 9
  • 27

2 Answers2

0

You also need to add a __init__.py file. See this question.

Community
  • 1
  • 1
zw324
  • 26,764
  • 16
  • 85
  • 118
0

Not very nice but adding

import sys
sys.path.append('./qanta/util')

and importing with from ... import * solved the problem

KameeCoding
  • 693
  • 2
  • 9
  • 27