linux command line to execute Python program prompts no moudle, routing problem

Ide python program execution, the project has set a good path.

However, the implementation of the program in cmd, where path is the search path of python, if it comes to import references will report similar ImportError: such errors No module named xxx,

Solution:

In the module error added:

import sys
import os
curPath = os.path.abspath(os.path.dirname(__file__))
rootPath = os.path.split(curPath)[0]
sys.path.append(rootPath)

Guess you like

Origin www.cnblogs.com/ywheunji/p/11865073.html