Common error

If you encounter the following error when you run the program, check whether you still can access the FTP_SERVER_URL, by pinging to it:

Traceback (most recent call last):
  File "5_1_list_files_on_ftp_server.py", line 25, in <module>
    email='[email protected]', 
  File "5_1_list_files_on_ftp_server.py", line 13, in test_ftp_connection
    ftp = ftplib.FTP(path, username, email)
 File "/usr/lib/python3.5/ftplib.py", line 118, in __init__
    self.connect(host)
  File "/usr/lib/python3.5/ftplib.py", line 153, in connect
    source_address=self.source_address)
  File "/usr/lib/python3.5/socket.py", line 693, in create_connection
   for res in getaddrinfo(host, port, 0, SOCK_STREAM):
  File "/usr/lib/python3.5/socket.py", line 732, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known
  

Usually, the preceding error means the FTP does not exist anymore, or is not open any more with the anonymous access.

If so, replace the URL with another FTP address that allows anonymous access.

You may verify that the FTP address is valid by trying to open it through your FTP client:

$ ftp
ftp> open ftp.ed.ac.uk
Connected to luther.is.ed.ac.uk.  

Give anonymous and your email address as the username and password when prompted. The outcome is depicted in the following screenshot:

Accessing the FTP Server
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.218.171.212