pythonimportftputil

Unable to import ftputil in Python


I am trying to delete ftp file using Spyder (python 3.8), but one of the import "ftputil" is not working. Error code looks like

import ftputil ModuleNotFoundError: No module named 'ftputil'

code

 #! /usr/bin/python
 import time
 import ftputil
 host = ftputil.FTPHost('host', 'username', 'password')
 mypath = 'ftp_dir'
 now = time.time()
 host.chdir(mypath)
 names = host.listdir(host.curdir)
 for name in names:
   if host.path.getmtime(name) < (now - (3600)):
     if host.path.isfile(name):
        host.remove(name)
 host.close()

Can we use another import, if it is not working.


Solution

  • try to install it using this instruction:

    conda install -c conda-forge ftputil
    

    for more info check this page