尽管添加到路径,python 2.7将不会导入

时间:2017-12-10 10:36:39

标签: python python-2.7

谜我......

导入包灾难..为什么?

contents of yenlib:
   /var/yenlib
       - __init__.py
       - yenlib
            - __init__.py
            - json_.py

import sys
sys.path.append('/var/yenlib')
sys.path.append('/var/yenlib/yenlib')

from yenlib import json_ as json
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name json_

1 个答案:

答案 0 :(得分:0)

跳过第二个&#34;追加&#34;声明并从yenlib.yenlib导入

import sys
sys.path.append("/var/yenlib")

from yenlib.yenlib import json_ as json