![]() |
"[Errno 2] No such file or directory" (.py file) - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: "[Errno 2] No such file or directory" (.py file) (/thread-42280.html) Pages:
1
2
|
"[Errno 2] No such file or directory" (.py file) - IbrahimBennani - Jun-10-2024 Hi to you all, I am reaching out due to an issue while trying to run a ".py" file on Windows 11 Home Single Language. After entering this on the command prompt: py C:\Users\ibrah\AppData\Roaming\Microsoft\Windows\Start%20Menu\Programs\Python%203.12\Waterfall%20Chart .pythe following error code is rendered I verified the exact name of the file, as well as its path several times and they are both correct.Does anyone see anything wrong with this line of code? Please find attached a screenshot for the actual line of code entered and the error message rendered on the command prompt Greetings. RE: "[Errno 2] No such file or directory" (.py file) - menator01 - Jun-10-2024 Does the file exist? What is in the file waterfall chart.py? RE: "[Errno 2] No such file or directory" (.py file) - snippsat - Jun-10-2024 You should not have folder %20 in name,Just make new folder with much shorter path easier to work with,place your Python files there. From eg cmd .# Cd down C:\Users>cd .. # Make a folder C:\>mkdir my_code # cd in C:\>cd my_code # Make a file C:\my_code>echo.> hello.py # Look at files in folder C:\my_code>dir Volume in drive C has no label. Volume Serial Number is EED7-45CC Directory of C:\my_code . 10.06.2024 21:49 <DIR> .. 10.06.2024 21:49 2 hello.py 1 File(s) 2 bytes 2 Dir(s) 17 600 786 432 bytes free # Run code,i have added print('hello world') C:\my_code>python hello.py hello world C:\my_code>py hello.py hello world # Test python and pip version C:\my_code>python --version Python 3.12.2 C:\my_code>pip --version pip 24.0 from C:\Python312\Lib\site-packages\pip (python 3.12) C:\my_code> RE: "[Errno 2] No such file or directory" (.py file) - IbrahimBennani - Jun-10-2024 (Jun-10-2024, 07:11 PM)menator01 Wrote: Does the file exist? I created the file yesterday at 9:55:55 under the name "Waterfall Chart". Here is its content: [attachment=2902] RE: "[Errno 2] No such file or directory" (.py file) - IbrahimBennani - Jun-10-2024 (Jun-10-2024, 07:59 PM)snippsat Wrote: You should not have folder Thank you for your answer. I moved the file to another folder easier to locate. I also tried running the line of code this way, without the %20 portion in the name of the file, however the following was rendered: C:\Users\ibrah\AppData\Local\Programs\Python\Python312\python.exe: can't open file 'C:\\Users\\ibrah\\Waterfall': [Errno 2] No such file or directoryWhen not using %20 instead of the space between "Waterfall" and "Chart", the following name: "Waterfall'"gets rendered instead of "Waterfall Chart".Does the location of the file has any incidence on its execution? Does it have to be at a specific place for it to be executed, for example, in "Python 3.12" for a file to be executed with the "py" command? RE: "[Errno 2] No such file or directory" (.py file) - deanhystad - Jun-10-2024 You should use quotes around filenames that contain spaces. "C:\Users\ibrah\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Python 3.12\Waterfall Chart.py" or you can use quotes only where needed C:\Users\ibrah\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\"Python 3.12"\"Waterfall Chart.py" %20 does not work at all. Where did you get that? The indenting in your waterfall chart.py file looks like a waterfall. You'll need to fix that. Indenting in python is syntax. RE: "[Errno 2] No such file or directory" (.py file) - perfringo - Jun-11-2024 (Jun-10-2024, 08:57 PM)IbrahimBennani Wrote: I created the file yesterday at 9:55:55 under the name "Waterfall Chart". Here is its content: I observe that filename on screenshot is Waterfall Plot and you try to open Waterfall Chart .
RE: "[Errno 2] No such file or directory" (.py file) - IbrahimBennani - Jun-11-2024 (Jun-10-2024, 09:59 PM)deanhystad Wrote: You should use quotes around filenames that contain spaces. The quote work indeed, but the same error message still gets rendered. C:\Users\ibrah\AppData\Local\Programs\Python\Python312\python.exe: can't open file 'C:\\Users\\ibrah\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Pyton 3.12\\Waterfall Chart.py': [Errno 2] No such file or directoryAs for "%20", it is an ASCII encoding reference, which you can find here: https://www.w3schools.com/tags/ref_urlencode.ASP I'll fix this for the indenting, however I am still struggling with the execution of the file for the moment. RE: "[Errno 2] No such file or directory" (.py file) - IbrahimBennani - Jun-11-2024 (Jun-11-2024, 05:00 AM)perfringo Wrote:(Jun-10-2024, 08:57 PM)IbrahimBennani Wrote: I created the file yesterday at 9:55:55 under the name "Waterfall Chart". Here is its content: True Perfringo, it is just the same file with two different names. Both do not get executed when I use the "py" command. RE: "[Errno 2] No such file or directory" (.py file) - IbrahimBennani - Jun-11-2024 I actually succeeded to run the file by using quotation marks instead of the "%20" encoding reference, however, another error message was rendered when running the file: C:\Users>py "C:\Users\ibrah\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Python 3.12\Waterfall Plot.py" The first element referred to by the "SyntaxError" message is a parenthesis while the second one is actually a hook. There might be a confusion between both elements.Here is the code contained in the file that was run through the "py" command: import plotly.graph_objects as go fig = go.Figure(go.Waterfall( measure = ["relative", "relative", "total", "relative", "relative, "total"] "Sales x = ["Sales", "Consulting", "Net revenue", "Purchases", "Other Expenses", "Profit Before Tax"], textposition = "outside" text = ["+60", "+80", "" "-40", "-20", "Total"] y = [60, 80, 0, -40, -20, 0] connector = "line":{"color":"rgb(63, 63, 63)"},) |