如何在项目中导入模块?

时间:2015-10-24 16:50:07

标签: python intellij-idea pythonpath

我的项目中有一个包ipin.crawler.base.common,我想在文件中导入此模块,如下所示:

from ipin.crawler.base.common import CommonConfig

我在Intellij IDEA中运行该文件,没关系,但我在bash中运行文件,它会引发ImportError: No module named crawler.base.common

我观察到Intellij IDEA add source roots to PYTHONPATH,那么如何在bash中运行文件?

1 个答案:

答案 0 :(得分:0)

好的,这是我的错,我应该用

export PYTHONPATH=/Users/roger/python/base_crawler_py

而不是

PYTHONPATH=/Users/roger/python/base_crawler_py
相关问题