I'm trying to download a couple of files (csv, pdf, ..) on a FTP server by using a Python library called urllib.request.
I made this code who unfortunately doesn't word since I'm getting an error.
import urllib.request
urllib.request.urlretrieve('ftp://user_name:password@host_name:port_number/users/appli/gedftp/data/BO/LME/TEST_CSV_INTE.csv', 'file')
URLError: <urlopen error ftp error: error_perm('550 users/appli/gedftp/data/BO/LME: No such file or directory.')>
Yet, in FileZilla, I can see that the directory/file exists.
Here is .xml configuration of the FTP server in FileZilla (I didn't put the real info) :
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<FileZilla3>
<Servers>
<Server>
<Host>host_name</Host>
<Port>port_number</Port>
<Protocol>0</Protocol>
<Type>0</Type>
<User>gedftp</User>
<Pass>password</Pass>
<Account>test</Account>
<Logontype>4</Logontype>
<TimezoneOffset>0</TimezoneOffset>
<PasvMode>MODE_DEFAULT</PasvMode>
<MaximumMultipleConnections>0</MaximumMultipleConnections>
<EncodingType>Auto</EncodingType>
<BypassProxy>0</BypassProxy>
<Name>server_name</Name>
<Comments />
<LocalDir />
<RemoteDir />
<SyncBrowsing>0</SyncBrowsing>server_name

</Server>
</Servers>
</FileZilla3>
I get the same problem with ftplib :
import ftplib
FTP_HOST = "host_name"
FTP_USER = "gedftp"
FTP_PASS = "password"
ftp = ftplib.FTP(FTP_HOST, FTP_USER, FTP_PASS)
ftp.encoding = "utf-8"
filename = "/users/appli/gedftp/data/BO/LME/TEST_CSV_INTE.csv"
with open(filename, "rb") as file:
# Command for Uploading the file "STOR filename"
ftp.storbinary(f"STOR {filename}", file)
FileNotFoundError: [Errno 2] No such file or directory: '/users/appli/gedftp/data/BO/LME/TEST_CSV_INTE.csv'
Do you have any idea how to fix this or any other proposition ?
As answered in the comment, it seems that you have used the file path /users/appli/gedftp/data/BO/LME/TEST_CSV_INTE.csv
in your local code and trying to open it on your local machine, while you were actually referencing a file which is located on server.
That's why opening the file locally failed :)