Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problems with windows paths
#7
delphinis Wrote:_tkinter.TclError
Observe that the error doesn't come from Python, it comes from the Tcl/Tk library upon which tkinter is sitting. This library may well accept only valid OS paths.

I'm not in the best position to answer, since I think a very good solution would be to get rid of the Windows OS...

More seriously, using the pathlib library to manipulate paths is a robust solution. Starting with Python 3.6, you can also use os.fspath, for example
import os
from pathlib import Path
filename = Path.cwd() / 'spam.png'
astring = os.fspath(filename) # see if this returns a valid Windows path
In good old python 1, 2, 3, one would have written
import os
astring = os.path.join(os.getcwd(), 'spam.png')
Reply


Messages In This Thread
Problems with windows paths - by delphinis - Jul-21-2020, 11:03 AM
RE: Problems with windows paths - by deanhystad - Jul-21-2020, 02:38 PM
RE: Problems with windows paths - by delphinis - Jul-21-2020, 03:17 PM
RE: Problems with windows paths - by deanhystad - Jul-21-2020, 03:24 PM
RE: Problems with windows paths - by delphinis - Jul-21-2020, 04:17 PM
RE: Problems with windows paths - by deanhystad - Jul-21-2020, 05:56 PM
RE: Problems with windows paths - by Gribouillis - Jul-21-2020, 06:11 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  pdf2image, poppler and paths jehoshua 18 14,782 Jun-14-2022, 06:38 AM
Last Post: jehoshua
  Windows paths issue otalado 3 1,476 May-29-2022, 09:11 AM
Last Post: snippsat
  automatically get absolute paths oclmedyb 1 2,128 Mar-11-2021, 04:31 PM
Last Post: deanhystad
  chkFile with absolute paths JarredAwesome 7 3,023 Sep-21-2020, 03:51 AM
Last Post: bowlofred
  Paths millpond 12 5,229 Jul-30-2020, 01:16 PM
Last Post: snippsat
  Shortest paths to win snake and ladder sandaab 5 4,268 Jun-30-2019, 03:20 PM
Last Post: sandaab
  How to handle paths with spaces in the name? zBernie 1 6,746 Nov-22-2018, 04:04 AM
Last Post: ichabod801
  Question: Paths and writing to a file mwmaw 6 6,519 Dec-20-2016, 03:44 PM
Last Post: wavic

Forum Jump:

User Panel Messages

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