Problem: Project-Customized packages, Python often cannot find packages when executing python Find the path to the package: the Lib package under the Python installation path and the package under Pythonpath you can use [Sys.path] to print out the path for Python to find a packageImport SYSSyspath=sys.path
However, when Jenkins runs, it is often prompted to not find the package, so you need to add pythonpath manually, by appending the Sys.path list to implement For example, the following way: Import OSImport SYSrootpath=str ("directory where the project is located")Syspath=sys.path
sys.path=[]
sys.path.append (rootpath) #将工程根目录加入到python搜索路径中
Sys.path.extend ([Rootpath+i for I in Os.listdir (rootpath) if i[0]!= "."]) #将工程目录下的一级目录添加到python搜索路径中sys.path.extend (Syspath) Description: Because I was built with Pycharm a project, I encountered the problem is not found under the project directory, so added the project directory and his next level directory I first use sys.path=[] to clear him, and then append the default path, because I have a package in the project may overlap with other paths, if put in the back of the error. So I put the path in front of it .
Python find the path to the package (problem solving for custom packages not found)