import xxx, the default path that pyhon used to find the xxx package is sys.path。
The script:
import os
import sys
import pythonApi# your own python pkg
print(sys.executable) #python解释器的路径
print(sys.path) # python包的搜索路径 ------------line #
print(type(sys.path)) #list
sys.path.append('/home/xx') # add your own path to sys.path
print(sys.path)
The output of line # is as follows, a list:
['/home/xx/Documents/myGitHub/playGround/pybinder/python2cpp', '/usr/lib/python38.zip', '/usr/lib/python3.8', '/usr/lib/python3.8/lib-dynload', '/home/fanggang/.local/lib/python3.8/site-packages', '/usr/local/lib/python3.8/dist-packages', '/usr/lib/python3/dist-packages']
The first element is the path of the script. If you want to import your own python pkg, pythonApi, you must put it in one of the paths in the list.
|