-1

I have a .get() function to accept user input of a path link. Then use the user's input to change directory @ os.chrdir. But running the code gives me error as this:

os.chdir(bomlist) OSError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: ''

Anyway of working around this problem?

Here is the code.

import tkinter as tk , os
entry1 = tk.Entry(top, bd=5, width = 40)
bomlist = entry1.get()
os.chdir(bomlist) #error here
wb = openpyxl.load_workbook('excel.xlsx', data_only= True)

wovano
  • 4,543
  • 5
  • 22
  • 49
  • 1
    Put `print(repr(bomlist))` before the `os.chdir()` command to see what the result is. – wovano Mar 31 '22 at 05:35
  • Does this answer your question? [Python - os.rename() - OSError: \[WinError 123\]](https://stackoverflow.com/questions/21115580/python-os-rename-oserror-winerror-123) – wovano Mar 31 '22 at 05:36

1 Answers1

0

If you are using tkinter then I would recommend opening the file using the from tkinter.filedialog import askopenfilename

So your code should be

path = askopenfilename()
wb = openpyxl.load_workbook(path, data_only= True)

It you want to trigger the opening function you can use a button so when the user clicks a button only then the dialog box pops up