I know how to install *.whl
files through cmd (the code is simply python -m pip install *so-and-so-.whl
). But since I accidentally deleted my OS and had no backups I found myself in the predicament to reinstall all of my whl files for my work.
This comes up to around 50 files. I can do this manually which is pretty simple, but I was wondering how to do this in a single line. I can't seem to find anything that would allow me to simply type in python -m pip install *so-and-so.whl
to find all of the whl files in the directory and install them.
Any ideas?
答案 0 :(得分:3)
在Windows import java.util.*;
public class Interface2 extends MovieDatabase
{
public static void main (String[] args)
{
Scanner console = new Scanner(System.in);
Movie movie1;
Movie movie2;
Movie movie3;
Movie movie4;
String name, director;
int size, duration, option;
int moviecount = 0;
movie1 = new Movie();
movie2 = new Movie();
movie3 = new Movie();
movie4 = new Movie();
do {
System.out.println("Import first movie:(0), View Movies: (1), Exit (9): ");
option = console.nextInt();
switch(option)
{
case 0:
if(moviecount <= 4)
{
System.out.print("name: ");
name = console.next();
movie1.setName (name);
System.out.print("Director: ");
director = console.next();
movie1.setDirector (director);
System.out.print("Size in MB: ");
size = console.nextInt();
movie1.setSize(size);
System.out.print("Duration in minutes: ");
duration = console.nextInt();
movie1.setDuration(duration);
moviecount++;
break;
}
else
System.out.print("Too many movies currently stored");
break;
case 1: System.out.print("Movies currently stored: ");
System.out.print(movie1.getName());
break;
}
}
while(option!=9);
}
}
中,您可以使用for循环执行此操作:
cmd
答案 1 :(得分:2)
另一种适用于大多数操作系统的更通用的方法是使用python解释器运行它:
import glob, pip
for path in glob.glob("c:/path/to/wheel/files/*.whl"):
pip.main(['install', path])
答案 2 :(得分:0)
要在命令行上安装多个软件包,只需将它们作为空格分隔列表传递,例如:
pip install numpy pandas
答案 3 :(得分:0)
Pip不支持v10.0中的main。*
import glob
import subprocess
for path in glob.glob("c:/path/to/wheel/files/*.whl"):
subprocess.run(f'pip install {path}')
答案 4 :(得分:0)
在linux中,您可以执行以下操作:
for x in `ls /home/pip-packages`; do pip install $x; done
这将同时安装.whl和tar软件包。