Reputation: 1
Currently building a program which requires certain packages. I have created multiple scripts which automatically install these from a folder. Locally (with internet) this works fine, but on the server (no internet) it keeps trying to connect to the internet.
I've put the packages in a folder and I refer to this folder in the Python script.
Following code works locally, but not on the server:
import os
os.chdir(os.path.dirname(os.getcwd()))
importpath = os.getcwd() + '\Packages'
os.chdir(importpath)
try:
from openpyxl import load_workbook
print('Openpyxl is already installed')
except ImportError:
from pip._internal import main as pip
pip(['install', '--user', 'openpyxl-2.5.11.tar.gz'])
from openpyxl import load_workbook
How can I make it so that PIP will only install from the specific tar.gz and will not try to connect to the internet?
Edit: Install paths have to be relative
Upvotes: 0
Views: 6916
Reputation: 8636
Use --find-links
argument.
Following example installs package from current directory and all dependencies would be searched in ~/packages
pip3 install --find-links=~/packages .
Upvotes: 2