Use à Python 2 module with Python 3

Steven D'Aprano steve+comp.lang.python at pearwood.info
Mon Mar 9 19:47:51 EDT 2015


Michael Parchet wrote:

> Hello,
> 
> For a new project, a person recommande me to use Python 3
> 
> can I use Python 3 with a Python 2 y module ex : pyQt 4 ?

Maybe.

If the module is really only Python 2, then no. If it is pure-Python, with
no C extensions, then you might be able to fork it and update it to work
with Python 3. The 2to3 tool may help with that.

If a module's documentation says it works with Python 2, but doesn't mention
Python 3 at all, it *might* work with Python 3. The author or maintainer of
the project simply hasn't gotten around to fixing the documentation. So it
may be worth just trying it and seeing for yourself.

For PyQt specifically, googling suggests that PyQt does work with Python 3,
but the documentation is out of date and you may have difficulty installing
it:

https://www.google.com.au/search?q=pyqt+python3




-- 
Steven




More information about the Python-list mailing list