Search code examples
pythonwindowsubuntusite-packages

Can I copy paste Python 2.7 packages from lib/site-packages from Windows to Ubuntu?


I am moving to Ubuntu 22.04 from Windows 10 and I was wondering if I could skip installing again all the packages I did on my Windows 10 machine on Python 2.7. Is it possible to save the package folders and paste them into the Python installation folder in Ubuntu?


Solution

  • It depends on what those packages contain. I wouldn't expect that 100% of packages would work, so if you want to save time (and frustration), then reinstall all packages for Linux, or run Python in a Windows VM or in Wine.

    Details:

    • .dll files don't work on Linux. Linux has .so files (of different format) instead.

    • .pyc and .pyo files work only if the Python version and some compilation flags match exactly. This is unlikely: a random Python version (e.g. 2.7.x) on Windows won't match a random Python version (e.g. 2.7.y) on Linux.

    • .py files are usually system-independent, most of them will thus work unchanged.