0

I want to download files from requirement.txt file, but I need manually edit directory where I need to download them.

For example usual pip download:

!pip download -r C:/Users/Test/requirements.txt -d C:/Users/Test/whldir

But I want put it to function where will be variables for directories:

reqs = C:/Users/Test/requirements.txt
whls = C:/Users/Test/whldir
!pip download -r reqs -d whls 

Is this possible to do?

4
  • download from a Python script? just use string formatting and subprocess.Popen (or just the latter, it will concatenate it for you), so like subprocess.Popen(["pip", "download", "-r", reqs, "-d", whls]) (not sure about any extra arguments but this should work... I think) Commented Jul 20, 2022 at 7:50
  • @Matiiss The syntax !pip suggests the environment is Jupyter Notebook; the OP should have mentioned that and used proper tags. Commented Jul 20, 2022 at 7:59
  • @phd I was wondering what it was for, thanks for explaining... welp, haven't used Jupyter, not sure whether my comment is needed anymore then Commented Jul 20, 2022 at 8:02
  • pip itself has no such facility, but the environment probably has support for variables of some kind. You seem to be asking about ipython or Jupyter; could you please edit to clarify which tool you are asking about? Commented Jul 20, 2022 at 8:13

1 Answer 1

0

What is that exclamation mark? What language is it? Looks like shell or windows cmd.

For windows cmd:

set reqs=C:/Users/Test/requirements.txt
set whls=C:/Users/Test/whldir
pip download -r %reqs% -d %whls% 

For unix shells:

reqs="/Users/Test/requirements.txt"
whls="/Users/Test/whldir"
pip download -r $reqs -d $whls 
Sign up to request clarification or add additional context in comments.

2 Comments

"What is that exclamation mark? What language is it?" Python in a Jupyter Notebook. Exclamation mark is used to run shell commands.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.