FileNotFoundError Python Script

2024/10/5 14:57:21

I am trying to run a python script, .py in the windows command prompt.

I drag the script from my files into the command prompt window. I run it. Then, the script presents a prompt for me to enter the file I would like to parse. I am supposed to enter a file like this: filename.txt

When I go to do this, I get the FileNotFoundError. They are both located in my downloads folder. Any ideas as to why? I've tried a couple of things but having no luck.

The script must be performed this way because this is a script many people will use and it is likely that they will receive it and download it and the file to parse to their computer so it'll be located in their downloads folder.

When I created the script I did it in Notepad++ and had a separate folder where I put the file and script and it worked fine this way. I am just ensuring it works from the perspective of someone who's downloading it off an email or website, etc.

Thanks !

Answer

Yeah that happened to me a lot.

To solve it just write the whole directory of the file.

If you are in windows

c:\user\username\Desktop\file.txt

If you are in linux or mac:

/home/username/Desktop/file.txt
https://en.xdnf.cn/q/120279.html

Related Q&A

Filtered product of lists without repetitions

I need an efficient solution to find all combinations without repetitions of a given lists. It has to work like this: l1 = [1, 2, 3] l2 = [3, 4, 5] combinations(l1, l2) = [(2, 4), (3, 4), (1, 5), (1, 4…

int object is not callable only appears randomly

Sometimes this code works just fine and runs through, but other times it throws the int object not callable error. I am not real sure as to why it is doing so.for ship in ships:vert_or_horz = randint(0…

scraping css values using scrapy framework

Is there a way to scrap css values while scraping using python scrapy framework or by using php scraping. any help will be appreaciated

Access dict via dict.key

I created a dict source = {livemode: False}. I thought its possible to access the livemode value via source.livemode. But it doesnt work. Is there a way to access it that way?As a not source[livemode]…

Function not returning anything

My viewdef login(request):c = {}c.update(csrf(request))return render_to_response(request, login.html, c)def auth_view(request):username = request.POST.get (username, )password = request.POST.get (passw…

My entry box always returns PY_VAR1 value!!though Im using the .get function

please take a look at my code, its really simple I need to take the value from the entry box and use it in my program and when pressing the add button I print it ,it keeps giving me this value PY_VAR1…

Arthimatic Quiz Not Accepting Correct Answers

I am attempting to make an arithmetic quiz, but have run into this issue: Even if I input the correct answer, it seems to ignore the correct answer code and go straight to the incorrect answer code. Ba…

Linux - Check if python script is running in screen and run if not [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.Want to improve this question? Update the question so it focuses on one problem only by editing this post.Closed 1…

Making Phonebook in python : i want to get this screen by fixing my current code

I made my code like below....But as i input the data such as spam & number, previous data is deleted.So id like to make multiple value in one key... (i think using list is kinda good method)For exa…

Adding enemies to a pygame platformer

Im new to pygame and trying to make a platformer game thats based on this tutorial: http://programarcadegames.com/python_examples/show_file.php?file=platform_scroller.pyI cant quite figure out how to …