0

I get this while running the code which worked some time ago. i tried to change import options aka from ftplib import *, etc, but no luck. Any help appreciated...

C:\blahblahblah>python ftp_client.py
Traceback (most recent call last):
  File "ftp_client.py", line 8, in <module>
    from ftplib import FTP
  File "C:\blahblahblah\ftplib.py", line 1
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtm
l11/DTD/xhtml11.dtd">
    ^
SyntaxError: invalid syntax

2 Answers2

1

Your copy of ftplib.py, which you have downloaded off the Web and placed in the same directory of your script (which is the first place Python searches for modules by default), is actually HTML, not Python source.

You should not need your own ftplib.py, since ftplib is in the standard library. Delete it and I suspect your script will work just fine.

Mattie
  • 20,280
  • 7
  • 36
  • 54
  • Yeah, I placed the script in the same folder accidentally and didn't notice that. Thanks! –  Oct 11 '12 at 19:35
0

You try to import C:\blahblahblah\ftplib.py file, which contains html code. I think it isn't what you want.

defuz
  • 26,721
  • 10
  • 38
  • 60
  • No, i use standard import notation `from ftplib import FTP`. I got your idea but it's not what happening, I guess. –  Oct 11 '12 at 19:23
  • 2
    Primarily python try to find `ftplib.py` file your current directory, and he finds it. – defuz Oct 11 '12 at 19:30