Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not compatible on different versions of Python #643

Open
znsoooo opened this issue Aug 5, 2024 · 3 comments
Open

Not compatible on different versions of Python #643

znsoooo opened this issue Aug 5, 2024 · 3 comments

Comments

@znsoooo
Copy link

znsoooo commented Aug 5, 2024

pyftpdlib version:

At latest: 66c8985

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.

@giampaolo
Copy link
Owner

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 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).

@znsoooo
Copy link
Author

znsoooo commented Aug 6, 2024

@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.

@giampaolo
Copy link
Owner

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants