[Tutor] FTP Errors
Peter Otten
__peter__ at web.de
Thu Jul 2 12:24:16 EDT 2020
John Weller wrote:
>>
>> > except ftplib.all_errors as err:
>>
>> Study the traceback carfully: the line above is the problem.
>> You probably wrote
>>
>> from ftplib import FTP
>>
>
> You were quite right!!
>
>> In both cases the name ftplib is not available to your module. To fix
>> this you can add the line
>>
>> import ftplib
>>
>> I recommend that for consistency you also change
>>
>> > ftp = FTP(data.ftp_host) # connect to host, default port
>>
>> to
>>
>> ftp = ftplib.FTP(data.ftp_host)
>
>
> Changed.
>
>> and remove the from ... import.
>>
> Not quite sure what this means?
I suppose you have a line
from ftplib import *
in your code? If so, remove that line. Instead add the line
import ftplib
As a consequence of that change you have to replace all occurences of
FTP
with
ftplib.FTP
More information about the Tutor
mailing list