Python Forum
Puzzling import issue that I have no idea how to solvr
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Puzzling import issue that I have no idea how to solvr
#2
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'

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.
Reply


Messages In This Thread
RE: Puzzling import issue that I have no idea how to solvr - by Pedroski55 - Feb-20-2024, 07:51 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Puzzling error PythonNewbee 1 1,421 Dec-10-2021, 05:51 PM
Last Post: deanhystad
  import psycopg2 issue bhuvneshdogra 1 3,053 Dec-27-2018, 04:03 PM
Last Post: Larz60+
  crypto import issue saisankalpj 2 7,980 Dec-20-2018, 06:08 AM
Last Post: saisankalpj
  Win10 Import math issue Oldsquid 2 3,142 May-12-2018, 11:08 AM
Last Post: Oldsquid

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020