Python Forum

Full Version: File not found error
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I am using pysftp module to connect to sftp server.After establishing the connection,I am trying to upload a file from my local to sftp server.For this ,I used
Sftp.put(localPath=“ C:/Users/documents/TestEDI.txt",remotePath=“ /Users/authentucation/")
This gives me error like
 FileNotFoundError: [Errno 2] No such file or directory: c:/Users/documents/TestEDI.txt
But i have the file present under documents folder.So this error comes when i run through pycharm and command prompt.Any suggestions on How to proceed further?
Sftp.put(localPath="C:/Users/documents/TestEDI.txt",remotePath="/Users/authentucation/")
(Jul-03-2022, 12:00 PM)Axel_Erfurt Wrote: [ -> ]Sftp.put(localPath="C:/Users/documents/TestEDI.txt",remotePath="/Users/authentucation/")

yes,this is what i have written in code.I still get the error
Are Windows filesystems case-sensitive? If so, have you got the casing correct? Could there be a permissions problem? I don't use Windows, so I don't know how permissions work on that OS. Can you upload files from anywhere else?
The Documents folder is under your Windows user name.
C:/Users/<username>/Documents/TestEDI.txt"
(Jul-03-2022, 09:32 AM)saisankalpj Wrote: [ -> ]
Sftp.put(localPath=“ C:/Users/documents/TestEDI.txt",remotePath=“ /Users/authentucation/")
Your localPath and remotePatch start with a space. I think this is not correct. Did you notice Axel Erfurt left out these spaces?
(Jul-03-2022, 05:38 PM)ibreeden Wrote: [ -> ]
(Jul-03-2022, 09:32 AM)saisankalpj Wrote: [ -> ]
Sftp.put(localPath=“ C:/Users/documents/TestEDI.txt",remotePath=“ /Users/authentucation/")
Your localPath and remotePatch start with a space. I think this is not correct. Did you notice Axel Erfurt left out these spaces?

Yes,i have removed the spaces and tried,still i get file nt found error.This is my code right now

Sftp.put(localPath=“C:/Users/sankalp/documents/TestEDI.txt",remotePath=“/Users/authentucation/")
N
(Jul-03-2022, 04:51 PM)snippsat Wrote: [ -> ]The Documents folder is under your Windows user name.
C:/Users/<username>/Documents/TestEDI.txt"

Yes,yes.I forgot to add it while posting in the forum.This is my code which still gives file not found, inspite of the file being present in that location
 Sftp.put(localPath=“C:/Users/sankalp/documents/TestEDI.txt",remotePath=“/Users/authentucation/")
Copy the path in Explorer and paste it into your code
You have two Unicode(Left Double Quotation Mark) in code posted,that will never work and you should get SyntaxError before file not found error.
>>> Sftp.put(localPath=“C:/Users/sankalp/documents/TestEDI.txt",remotePath=“/Users/authentucation/")
Error:
File "<interactive input>", line 1 Sftp.put(localPath=“C:/Users/sankalp/documents/TestEDI.txt",remotePath=“/Users/authentucation/") ^ SyntaxError: invalid character '“' (U+201C)
>>> Sftp.put(localPath="C:/Users/sankalp/documents/TestEDI.txt",remotePath=“/Users/authentucation/")
Error:
File "<interactive input>", line 1 Sftp.put(localPath="C:/Users/sankalp/documents/TestEDI.txt",remotePath=“/Users/authentucation/") ^ SyntaxError: invalid character '“' (U+201C)
Sftp.put(localPath="C:/Users/sankalp/documents/TestEDI.txt",remotePath="/Users/authentucation/")
Error:
Traceback (most recent call last): File "<interactive input>", line 1, in <module> NameError: name 'Sftp' is not defined
Pages: 1 2