offline python. for doing this I use virtualenv (isolated Python environment)
1) install virtualenv online with pip:
pip install virtualenv --user
or offline with whl: go to this link , download last version (.whl or tar.gz) and install that with this command:
pip install virtualenv-15.1.0-py2.py3-none-any.whl --user
by using --user
you don't need to use sudo pip…
.
2) use virtualenv
on online machine select a directory with terminal cd
and run this code:
python -m virtualenv myenv
cd myenv
source bin/activate
pip install Flask
after installing all the packages, you have to generate a requirements.txt
so while your virtualenv is active, write
pip freeze > requirements.txt
open a new terminal and create another env like myenv2
.
python -m virtualenv myenv2
cd myenv2
source bin/activate
cd -
ls
now you can go to your offline folder where your requirements.txt
and tranferred_packages
folder are in there. download the packages with following code and put all of them to tranferred_packages
folder.
pip download -r requirements.txt
take your offline folder to offline computer and then
python -m virtualenv myenv2
cd myenv2
source bin/activate
cd -
cd offline
pip install --no-index --find-links="./tranferred_packages" -r requirements.txt
what is in the folder offline [requirements.txt , tranferred_packages {Flask-0.10.1.tar.gz, ...}]
check list of your package
pip list
note: as we are in 2017 it is better to use python 3. you can create python 3 virtualenv with this command.
virtualenv -p python3 envname