Python from Linux to Windows

Linux (Host) internet machine

First install the Python and then install pip on linux machine.

$ wget http://osrepo.xyz.in/pypi/get-pip.py -O /tmp/get-pip.py
$ sudo python /tmp/get-pip.py -i http://osrepo.xyz.in/pypi/simple --trusted-host osrepo.xyz.in

In the host Linux system create /etc/pip.conf file. It shall have following entries.

# Contents of /etc/pip.conf	
[global]
index-url = http://osrepo.xyz.in/pypi/simple
trusted-host = osrepo.xyz.in
disable-pip-version-check = true

If you have created this file on desktop, move this file to /etc. You need to use the command after opening the shell in desktop,

$ sudo mv ./etc/

You can now use pip to install packages from the mirror

$ pip install YOUR_PACKAGE_NAME

For Python3 and if you have multiple pythons installed, you can use the alternate syntax

$ python -m pip install YOUR_PACKAGE_NAME

Note that python should be replaced with versioned python name such as python2 or python3.6 etc.

On linux machine use pip to download the package.

pip donwload -d ~/python_packages matplotlib  ----- download
python3 -m pip download matplotlib ----- installation

But this may download the packages for the host operating system. If you want specific python version and particular OS, use following command.

------download for specific version------

$ pip download plotly 
--platform win_amd64 \
--python-version 38 \
--only-binary=:all: \
--implementation cp \
--abi cp38 \
--dest ./python_packages
$ pip download plotly --platform win_amd64 --python-version 38 --only-binary=:all: --implementation cp --abi cp38 --dest ./python_packages

Check if the version is correct. e.g. numpy‑1.24.4‑cp310‑cp310‑win_amd64.whl here cp310 = CPython 3.10 and win_amd64 = 64-bit Windows. Also check is all the dependancies are downloaded.

Windows machine

Then go to Windows. Coply these files to a folder say (C:\offline_packages)

Start the cmd in administrator mode and go to that particular folder.

cd C:\offline_packages

Then install the package with following command.

$ pip install --no-index --find-links=. matplotlib

In this command,

  • --no-index: Prevents pip from accessing the internet
  • --find-links=.: Tells pip to look in the current folder for packages