-1

I want to download all the python packages mentioned in the requirement.txt to a folder in Linux. I don't want to install them. I just need to download them.

I want to write a python script that can download all the python packages.

python version is 3.6

list of packages in the requirement.txt

python-ldap==3.2.0
python-libnmap==0.6.2
python-otrs==0.4.3
pytz==2015.4
PyYAML==3.11
query-string==0.0.2
queuelib==1.2.2
redis==2.10.3
requests==2.22.1
requests-aws4auth==0.9
requests-oauthlib==0.5.0
requests-toolbelt==0.5.0
scp==0.10.2
six==1.10.0
South==1.0.1
tlslite==0.4.9
u-msgpack-python==2.1
urllib3==1.14
w3lib==1.12.0
websockets==3.3
Werkzeug==0.10.4
xlrd==1.0.0
XlsxWriter==1.0.5
zope.interface==4.1.2
GitPython==2.1.3
Smruti Sahoo
  • 149
  • 1
  • 9
  • Does this answer your question? [How to pip install git repository with requirements](https://stackoverflow.com/questions/20578146/how-to-pip-install-git-repository-with-requirements) – Simon Jun 30 '20 at 19:32
  • There's not much difference between installing and downloading. You could simply install all the packages to a virtualenv & get the packages from the `site-packages` folder – rdas Jun 30 '20 at 19:34

3 Answers3

0
import subprocess
import sys
command = [
    sys.executable,
    '-m',
    'pip',
    'download',
    '--dest',
    'path/to/target',
    '--requirement',
    'path/to/requirements.txt',
]
subprocess.check_call(command)

References:

sinoroc
  • 18,409
  • 2
  • 39
  • 70
  • @SmrutiSahoo Does that answer your question? Anything you might want to be clarified before accepting this answer? – sinoroc Jul 13 '20 at 11:07
-1

Just download the packages?

Then you can use pip command

pip download <package name>==<version>

If you want to make a python script, you can use subprocess

subprocess.check_call([sys.executable, '-m', 'pip', 'download', 
'<packagename>==<version>'])
-1

Usually you'd use:

pip install --target=/path/to/install/to -r requirement.txt

This should download all packages in requirement.txt to the path you specify.

CodinGuy
  • 33
  • 1
  • 5