2
from pyftpdlib import ftpserver

HOSTNAME = "localhost"
PORT = 5555

authorizer = ftpserver.DummyAuthorizer()
authorizer.add_user("papakri", "dancinghotdogs", "/Users/alexandrospapakribopoulos/Documents/Programming")
authorizer.anonymous("/Users/alexandrospapakribopoulos/Documents/Programming")
handler = ftpserver.FTPHandler
handler.authorizer = authorizer

connection = (HOSTNAME, PORT)
ftpd = ftpsserver.FTPServer(connection, handler)

ftpd.serve_forever()

I am trying to create a basic FTP and connect with and connect it with an HTTP server that I have created. I am a bit new to python so even if it is something really obvious please point it out. I am using python 2.7.10. Thanks in advance.

Kri Kri
  • 21
  • 1
  • 8

3 Answers3

1
Hamuel
  • 633
  • 5
  • 16
0

Make sure the package is installed:

pip install pyftpdlib

Make sure you did that with your virtual environment installed if you use one. Forget this sentence if you don't know what I'm talking about.

Then, according to the example from the repo, your code should be :

from pyftpdlib.authorizers import DummyAuthorizer
from pyftpdlib.handlers import FTPHandler
from pyftpdlib.servers import FTPServer

authorizer = DummyAuthorizer()
authorizer.add_user("user", "12345", "/home/giampaolo", perm="elradfmw")
authorizer.add_anonymous("/home/nobody")

handler = FTPHandler
handler.authorizer = authorizer

server = FTPServer(("127.0.0.1", 21), handler)
server.serve_forever()

Your snippet might be out of date vs your package version.

Julien Kieffer
  • 1,116
  • 6
  • 16
0

It seems you have osx operation system.for mac you can install python use brew like this:

brew install python

and then you have pip package manager for Python, then you can install pyftpdlib package with this command:

pip install pyftpdlib

and then you can try again to run your code

in summary I can say you can isntall packages in operation systems like this:

linuxbased with apt-get repository manager :

sudo apt-get install pip
pip install your_package_name

osx :

brew install python
pip install your_package_name

CentOS/RHEL

sudo yum install python-pip
pip install your_package_name
Ebrahim Poursadeqi
  • 1,776
  • 2
  • 17
  • 27