Not compatible on different versions of Python
pyftpdlib version:
At latest: 66c89850ffc50e8764502a482df06bbac07b07ef
Test code (from: #625):
import os
from pyftpdlib.servers import FTPServer
from pyftpdlib.handlers import FTPHandler
from pyftpdlib.authorizers import DummyAuthorizer
def main():
authorizer = DummyAuthorizer()
authorizer.add_anonymous(os.getcwd(), perm='elradfmwMT')
handler = FTPHandler
handler.authorizer = authorizer
handler.encoding = 'gbk'
address = ('127.0.0.1', 2121)
server = FTPServer(address, handler)
server.serve_forever()
if __name__ == '__main__':
main()
On PY36 and PY38:
Traceback (most recent call last):
...
File "H:\repos\pyftpdlib\pyftpdlib\handlers.py", line 3698, in TLS_FTPHandler
ssl_protocol = SSL.TLS_SERVER_METHOD
AttributeError: module 'OpenSSL.SSL' has no attribute 'TLS_SERVER_METHOD'
On PY12:
Traceback (most recent call last):
...
File "H:\repos\pyftpdlib\pyftpdlib\ioloop.py", line 78, in <module>
import asynchat
ModuleNotFoundError: No module named 'asynchat'
On PY10:
OK.
AttributeError: module 'OpenSSL.SSL' has no attribute 'TLS_SERVER_METHOD'
What PyOpenSSL version have you installed? E.g. mine is:
$ python3 -m pip freeze | grep SSL
pyOpenSSL==24.2.1
ModuleNotFoundError: No module named 'asynchat'
This was introduced in https://github.com/giampaolo/pyftpdlib/commit/eef16967. We now depend on asyncore/asynchat packages from PYPI. You should be able to fix this problem by reinstalling pyftpdlib, meaning running python3 setup.py install or re-installing it via pip + git@master (can't remember the exact syntax).
@giampaolo
What PyOpenSSL version have you installed?
I'm using the built-in "ssl" library of Python-3.6.8, so I can't find it in pip. (And I didn't find a version infomation in the source code)
We now depend on asyncore/asynchat packages from PYPI
I got it, I cloned the folder directly from github and then import it in the project folder. (so only the "~/pyftpdlib" folder is imported)
Use pip install pyasynchat can fix it.
I'm using the built-in "ssl" library of Python-3.6.8, so I can't find it in pip. (And I didn't find a version infomation in the source code)
pyftpdlib does not rely on ssl module from the standard library. It depends on https://pypi.org/project/pyOpenSSL/. This dependency is optional, meaning that if you don't pip install PyOpenSSL pyftpdlib will still work, but you won't be able to use FTPS.
With this said. Is this still an issue for you? setup.py has pyasyncore and pyasynchat as third-party deps, which should be automatically installed when you install pyftpdlib. Perhaps... could you confirm this is the case?