Trong test.py, tôi đang cố gắng để nhập khẩu test_data:ImportError: Không có mô-đun tên test_data, nhưng test_data.py trong cùng một thư mục như test.py dưới PyCharm sử dụng virtualenv
import unittest2
import re
from test_data import receipt1_example
test_data.py là trong cùng thư mục với test.py. Tôi nhận được lỗi sau:
/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 started at 11:30 AM ... Traceback (most recent call last):
File "/Applications/PyCharm.app/helpers/pycharm/utrunner.py", line 121, in module = loadSource(a[0]) File "/Applications/PyCharm.app/helpers/pycharm/utrunner.py", line 44, in loadSource module = imp.load_source(moduleName, fileName) File "/Users/ahammond/src/hackfest_spring_2012/parse_me/test.py", line 4, in from test_data import receipt1_example ImportError: No module named test_dataProcess finished with exit code 1
Như bạn có thể thấy, tôi đang chạy điều này dưới pycharm bằng virtualenv. Dưới đây là một ảnh chụp màn hình của cấu hình:
Xấu xí, nhưng hoạt động. Cảm ơn! Er, rõ ràng đang sử dụng từ biên lai nhập test_data1_example – Andrew