Chweng Mega
Chweng Mega

Reputation: 1658

How do you extract packages installed by pip and import onto another computer with no internet?

There is a project in another laptop which is unable to connect to the internet (Lan only), so pip install requests is impossible.

main.py:

import requests
r = requests.get('http://localhost/')

__

I've tried to copy certifi, chardet, idna, requests, urllib3 from site-packages and import without a problem when the dependency is in the same folder

Project
├── certifi
├── chardet
├── idna
├── main.py
├── requests
└── urllib3

__

But it can't be imported when dependency in subdirectory supportFiles

main.py:

import supportFiles.requests

Output : no module named urllib3...

Project                         
    ├── main.py
    └── supportFiles
        ├── __init__.py
        ├── certifi
        ├── chardet
        ├── idna
        ├── requests
        └── urllib

what should I do?

Upvotes: 6

Views: 7365

Answers (2)

ivo
ivo

Reputation: 1113

Use pip download (with older versions of pip, pip install --download <dir> <package-name>):

pip download requests

which will download the package and dependencies to current folder. Copy the packages to the laptop and then pip install using:

pip install <path-to-requests-package-file>

Upvotes: 7

Konstantin
Konstantin

Reputation: 69

You can use virtualenv to create an environment on the computer with an internet connection, install all required packages using the activated virtualenv

Then copy the folder with the prepared environment to the target laptop. Active the environment on the target laptop.

Upvotes: -2

Related Questions