skip to Main Content

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

3

Answers


  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>'])
    
    Login or Signup to reply.
  2. import subprocess
    import sys
    command = [
        sys.executable,
        '-m',
        'pip',
        'download',
        '--dest',
        'path/to/target',
        '--requirement',
        'path/to/requirements.txt',
    ]
    subprocess.check_call(command)
    

    References:

    Login or Signup to reply.
  3. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search