Python Forum
Can a windows file be 'remapped' in Linux ?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Can a windows file be 'remapped' in Linux ?
#1
Looking through some of the examples at https://github.com/flatplanet/Intro-To-T...ube-Course , tried running one and

Quote:$ python3 listbox.py
Traceback (most recent call last):
File "/home/***********/Downloads/python/flatplanet/Intro-To-TKinter-Youtube-Course/Intro-To-TKinter-Youtube-Course-master/listbox.py", line 5, in <module>
root.iconbitmap('c:/gui/codemy.ico')
File "/usr/lib/python3.12/tkinter/__init__.py", line 2155, in wm_iconbitmap
return self.tk.call('wm', 'iconbitmap', self._w, bitmap)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

As there are a few hundred Python scripts, I don't want to be changing the code. Can Python look for a file based on the PATH variable, or maybe a mount command to point , or some sort of remapping involved ?

C;/ equates to ??
Reply
#2
I generally use pathlib for creating paths. System doesn't matter then.
from pathlib import Path

# will be path of the executing script
path = Path(__file__).parent
jehoshua likes this post
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags
Download my project scripts


Reply
#3
Great example of why you should never use absolute paths. You could make a windows virtual machine to run windows on your Linux machine. How about using a script to process the files, changing c:gui to some other folder.
jehoshua and buran like this post
Reply
#4
(Dec-07-2024, 02:42 AM)menator01 Wrote: I generally use pathlib for creating paths. System doesn't matter then.
from pathlib import Path

# will be path of the executing script
path = Path(__file__).parent

Thanks yes, a hard coded pathname is not a good idea.


(Dec-07-2024, 02:59 AM)deanhystad Wrote: Great example of why you should never use absolute paths. You could make a windows virtual machine to run windows on your Linux machine. How about using a script to process the files, changing c:gui to some other folder.

Yes, certainly a script will be easier, .. modify on mass. Something like "How to replace a string in multiple files in linux command line" at https://stackoverflow.com/questions/1139...e#11392505
ndc85430 likes this post
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Windows, Linux and virtual environments Calab 2 447 Mar-07-2025, 10:43 PM
Last Post: snippsat
  How to re-register .py file extension to new moved Python dir (on Windows)? pstein 5 1,249 Nov-06-2024, 03:06 PM
Last Post: DeaD_EyE
  [SOLVED] [Linux] Write file and change owner? Winfried 6 1,491 Oct-17-2024, 01:15 AM
Last Post: Winfried
  Executable file compiled by PyInstaller does not work on Windows 7 amusaber 1 1,652 Jul-11-2024, 02:59 PM
Last Post: DeaD_EyE
  create exe file for linux? korenron 2 1,733 Mar-22-2023, 01:42 PM
Last Post: korenron
  How to compile a Python script for a Windows / Linux executable? netanelst 2 2,090 May-24-2022, 07:02 AM
Last Post: netanelst
  Resources for printing tabledata-Linux and Windows hammer 4 2,250 Apr-25-2022, 12:09 PM
Last Post: hammer
  batch file for running python scipt in Windows shell MaartenRo 2 2,956 Jan-21-2022, 02:36 PM
Last Post: MaartenRo
  Using a .bat file to execute simple anaconda commands in Windows 10 gacg1 0 5,749 Nov-30-2020, 03:24 PM
Last Post: gacg1
  multiprocessing difference between Linux and Windows direl 2 3,928 Oct-01-2020, 07:10 PM
Last Post: direl

Forum Jump:

User Panel Messages

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