0
我需要創建一個簡單的代碼,將一個.csv文件上傳到FTP服務器。代碼如下。Python ftplib:socket.gaierror:[Errno -3]名稱解析中的臨時失敗
import ftplib
import os
import sys
sourceFilePath = '/home/user/dir/'
filename = 'testing.csv'
destinationDirectory = 'anotherDirectory'
server = 'ftp://12.123.12.234'
username = 'aUser'
password = 'passwd1234'
myFTP = ftplib.FTP(server, username, password)
myFTP.cwd('/anotherDirectory/')
myFTP.storbinary('STOR '+filename, open(filename,'rb'))
myFTP.quit()
然而,當我運行代碼,我得到以下錯誤:
Traceback (most recent call last):
File "./UploadToFTP.py", line 20, in <module>
File "./UploadToFTP.py", line 13, in uploadFileFTP
myFTP = ftplib.FTP(server, username, password)
File "/usr/lib64/python2.6/ftplib.py", line 119, in __init__
self.connect(host)
File "/usr/lib64/python2.6/ftplib.py", line 134, in connect
self.sock = socket.create_connection((self.host, self.port),
self.timeout)
File "/usr/lib64/python2.6/socket.py", line 553, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
socket.gaierror: [Errno -3] Temporary failure in name resolution
有沒有人見過這個?這對我來說似乎相當通用,並沒有告訴我很多。就我見過的其他代碼執行相同的任務而言,我目前沒有任何可見的錯誤。任何幫助,將不勝感激。
有沒有* 「未決定錯誤」 *任何地方你的消息。 –
這是我無法確定的。 ;) –