Reputation: 2996
This question gets asked a lot, but there's never a satisfactory answer.
Here's my situation. I'm working at a secure facility. My desktop system can connect to the internet, but I'm not allowed to install unapproved software, included Python. There's a lab where Python 2.7 and 3.7 are installed, but it doesn't have internet access. I've downloaded example-1.0.0.tar.gz from PyPy and copied to a lab server, but pip says it wants requests==2.9.1 to be installed. I can do that, but I'd really like to get a list of everything I'll be needing and do them all at one time.
I could install the package at home and then use "pip show", but it's something of no use at home, so I'll want to uninstall it once I'm done and that seems like a lot of effort.
Any ideas?
Upvotes: 0
Views: 77
Reputation: 3959
Create virtual environment on a machine that has internet access and use the --copies
option to ensure files are not symlinked. Afterwards copy the whole environment to the target machine and use it there.
# create the environement
python3 -m venv venvfoldername --copies
# activate the environment
. venvfoldername/bin/activate
# install your requirements together with their dependencies
pip install -r requirements.txt
# copy everything to target machine
scp -r venvfoldername labhostname:/path/on/the/server
# connect there and activate the environment
ssh labhostname
cd /path/on/the/server/
. venvfoldername/bin/activate
# you can also use it like that
/path/on/the/server/venvfoldername/bin/python foobar.py
You should have everything at hand now.
Upvotes: 1