-1

Following is my python code to make a FTP connection

upload_ftp.py

import ftplib
ftp = ftplip.FTP()
ftp.connect('ip', 21)
print ftp.getwelcome()
try:
    print "Logging in..."
    ftp.login("username", "password")
except:
    "failed to login"

but when i run the code ,i get the following error: NameError:name 'ftplib' is not defined

my@my-pc:/var/www$ python upload_ftp.py 
Traceback (most recent call last):
  File "upload_ftp.py", line 8, in <module>
    ftp1 = ftplip.FTP()
NameError: name 'ftplip' is not defined

Any help would be appreciated..

amit_183
  • 961
  • 3
  • 19
  • 36

3 Answers3

1

You have a spelling error in your variable name. So Python thinks you are using an undefined variable.

Michael Murphy
  • 1,921
  • 2
  • 18
  • 21
0

Use :

from ftplib import FTP
ftp = FTP()

Return a new instance of the FTP class.

user3273866
  • 594
  • 4
  • 8
0

You have a typo: you writing ftplip.FTP() but it is ftplib.FTP() (lip with p vs lib with b).

semptic
  • 645
  • 4
  • 15