python: How to install virtualenv without internet connection
python: How to install virtualenv without internet connection
I am filling in for someone while they are on vacation and I am new to python. I've been asked to install several packages in a virtual environment. The big catch is the server cannot be on a public net so I will be downloading the software on a different server and copying it to the server where the researcher will be working.
I found another thread "Install Virtualenv without internet connectivity" at Install Virtualenv without internet connectivity, but that doesn't fit the situation I am in - it looks like they can start from a server on the net to complete their installs and want to share that virtualenv to other systems in a lab environment that may not have Internet connectivity.
Another thread "python: How to create virtualenv without internet connection" at python: How to create virtualenv without internet connection, is similar but it looks like they already have virtualenv installed. I don't find virtualenv installed here.
This Windows Server 2016 system is locked down where I cannot copy and paste the commands I ran to provide the information below, so forgive any typos in the hastily written message. I found the python version installed by:
python --version
Python 3.6.2rc1
I have not been able to find an installer to download for virtualenv. Do I need to download the Python installer again, re-run it and select additional options?
Thank you for any help you are able to provide.
edited to add:
Based on feedback, I changed the command (in an administrative command window) topython -m venv [path]
and I have been able to make some progress.
python -m venv [path]
I have the ability to download gz, whl or other files and move them to this server to run them there, but this server cannot be put online to download the installers directly nor can it connect to a repo to download dependencies. I cannot set up the environment on a different machine that has connectivity and share it without violating the security requirements. Thank you for the link to the Python Package Offline Installation thread - I think I was so narrowly focused on the virtual environment that I missed that post.
The command is
python -m venv
. Getting the packages you need is still a problem, but this is a common FAQ.– tripleee
Aug 31 at 16:42
python -m venv
Given that installing any Python package is likely to require downloading transitive dependencies, I'm not sure you can do better than preparing a setup environment on a machine with connectivity and sharing that. Can you provide more details on what exactly is different between your problem and the one you linked? Maybe outline the sequence of events - what you expect to be downloaded on a machine that is connected, and what commands should work on the one that is not?
– millimoose
Aug 31 at 16:56
1 Answer
1
You're using Python 3.6, which means venv
is included and pip
can be bootstrapped if necessary. Creating a venv does not need internet access:
venv
pip
python3 -m venv .venv --prompt=myvenv
Installing pip does not require internet access:
python3 -m ensurepip
Installing a package from a local file does not require internet access:
python3 -m pip install --no-index --disable-pip-version-check ./mydist.tar.gz
Should you have more than one package to install (for example, if mydist
has dependencies) you may specify a local directory as your --index-url
instead of the index defaulting to PyPI.
mydist
--index-url
A solution for people on older versions of Python is covered here.
Thank you. I will give this a go.
– Be_in_NY
Aug 31 at 20:11
Thanks for contributing an answer to Stack Overflow!
But avoid …
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
But avoid …
To learn more, see our tips on writing great answers.
Required, but never shown
Required, but never shown
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
How would you like to retrieve the required packages if you don't have an internet connection and cannot access the machine's file system ?
– gogaz
Aug 31 at 16:41