HoopsMcCann
HoopsMcCann

Reputation: 347

Package Python project along with dependencies to another machine without internet and different OS

As the title suggests, I have a computer running mac os with a python project. I so have a windows computer without internet, with Python 3.6, and with pip.

The project in question relies on a couple pip package dependencies. Is there anyway to package everything together so that the project can work on the windows machine with no internet?

Upvotes: 2

Views: 494

Answers (1)

phd
phd

Reputation: 94463

To some extent pip allows to download a package with dependencies for a different platform. Try

pip download --only-binary=:all: --platform win_amd64 --implementation cp --python-version=3.6 --abi=cp36m 'put-your-package-name-here'

If the package and all its dependencies provide binary wheels pip downloads all of them into the current directory. Move them to the offline computer and run there

pip install --find-links=\path\to\wheels\directory 'your-package'

If the package and all its dependencies provide only source distribution try

pip download --only-binary=:none: --platform win_amd64 --implementation cp --python-version=3.6 --abi=cp36m 'your-package'

But if the package and dependencies are mixed — some have binary wheels and some only sdists — pip fails to download dependencies. There is no solution for this situation. The only workaround is to run Windows on your MacOS — in an emulator or a container.

PS. I use platform win_amd64 as an example. If you have 32-bit Windows or if you have 32-bit Python on a 64-bit Windows — use platform win32.

Upvotes: 1

Related Questions