1, adding temporarily with a function
1 Import sys # importing sys module 234 sys.path.append (R' /tmp/test') # to use absolute path 5print(sys.path) # View Module Path
2, add it permanently, add it in the third-party module directory. PTHsuffix name file
Ubuntu The third-party module directory is named: dist-packages
Windows and the Redhat The third-party module directory is named: site-packages
Test Example:2.1Createtest.pyfile that is used to view the currentpythonModule Path
cat >>test.py<<eofimport sysprint (sys.path) EOFcat test.py
2.2 Viewing the current Python module path
Python test.py
2.3 Adding a module path
The third-party module directory path here is:/usr/lib/python2.6/site-packages
The module path to add is:/tmp/test/
mkdir -p/tmp/testecho"/tmp/test/">/usr/lib/python2. 6/site-packages/mytest.pthcat /usr/lib/python2. 6/site-packages/mytest.pth
2.4 Verify success or not
Python test.py
Success!!!
Python Add module path