Feb-20-2024, 07:51 AM
I would just check the paths first, to see if what you seek is actually in the path you are using.
I don't use Windoze so I am not familiar with the paths.
I keep my home-made modules in '/home/pedro/myPython/myModules'
Or you can specifically search for any particular file and, if found, print its full path.
I don't use Windoze so I am not familiar with the paths.
I keep my home-made modules in '/home/pedro/myPython/myModules'
from pathlib import Path # set starting directory # winpath = Path("C:\Correlator") path2modules = Path('/home/pedro/myPython/myModules') # if you have various subdirectories, you can loop through them # I don't have subdirectories! dirs = [d for d in path2modules.iterdir() if d.is_dir()] # this to find all files in your path path2modules = Path('/home/pedro/myPython/myModules') filelist = [filename for filename in path2modules.iterdir() if filename.is_file()] for filename in filelist: print(f"\nfilename: {filename.name}") print(f"file suffix: {filename.suffix}") print(f"full path: {filename.resolve()}") print(f"filepath parts: {filename.parts}")Example output:
Output:filename: makeWebpage.py
file suffix: .py
full path: /home/pedro/myPython/myModules/makeWebpage.py
filepath parts: ('/', 'home', 'pedro', 'myPython', 'myModules', 'makeWebpage.py')
I see sometimes people use r' before the path. Not sure why. In case of funny characters or spaces perhaps.Quote:dest = r'C:\Test'
Or you can specifically search for any particular file and, if found, print its full path.