简体   繁体   English

pip 将 -r 要求安装到 Colab 中的特定目录

[英]pip install -r requirements to a specific directory in Colab

I have found that I can pip install packages to a certain directory using:我发现我可以 pip 使用以下命令将软件包安装到某个目录:

!pip install --target='/content/drive/Mydrive/requirements' <package_name>

In the above case, I can see <package_name> in the folder '/content/drive/Mydrive/requirements'.在上述情况下,我可以在文件夹“/content/drive/Mydrive/requirements”中看到 <package_name>。 However, when I install packages from a file, 'requirements.txt', the packages do not go into the target directory, namely:但是,当我从文件“requirements.txt”安装包时,包不会 go 进入目标目录,即:

!pip install --target='/content/drive/Mydrive/requirements' -r requirements.txt

Does not install the packages in 'requirements.txt' into '/content/drive/Mydrive/requirements'.不将“requirements.txt”中的包安装到“/content/drive/Mydrive/requirements”中。

Can somebody please help?有人可以帮忙吗? Thanks!谢谢!

I realized what was needed... (below)我意识到需要什么......(下)

.pip install -r requirements.txt -t "target_dir" .pip 安装-r requirements.txt -t "target_dir"

I think where the "-r" flag is seemed to matter, but then again I had tried that but it didn't work before.我认为“-r”标志的位置似乎很重要,但我又试过了,但以前没有用。 However, what I have here does work.但是,我这里的东西确实有效。

pip3 install "package_name" -t "target_dir"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM