我想从包abc.devices导入一个模块Devices.py,但它给我一个导入错误:没有名为abc的模块。这里的dev是一个包,其中包含Devices.py模块。下面是我的monkeyrunner文件的代码。
import os
import sys
import subprocess
import unittest
import commands
from ConfigParser import ConfigParser
from abc.Devices import Devices
dev = Devices()
dev.gDevice()
from com.android.monkeyrunner import MonkeyDevice, MonkeyRunner, MonkeyImage
from com.dtmilano.android.viewclient import ViewClient, View
答案 0 :(得分:0)
monlyrunner没有阅读PYTHONPATH,所以你必须在导入模块之前这样做(如ViewClient的例子那样):
# PyDev sets PYTHONPATH, use it
try:
for p in os.environ['PYTHONPATH'].split(':'):
if not p in sys.path:
sys.path.append(p)
except:
pass