我试过几次安装pip但是没有。这是我的终端在尝试安装pip时的样子:
aman@aman-HP-Pavilion-Notebook:~$ sudo apt-get install python-pip
Reading package lists... Done
Building dependency tree
Reading state information... Done
python-pip is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
aman@aman-HP-Pavilion-Notebook:~$ pip
The program 'pip' is currently not installed. You can install it by typing:
sudo apt-get install python-pip
aman@aman-HP-Pavilion-Notebook:~$ sudo pip
sudo: pip: command not found
aman@aman-HP-Pavilion-Notebook:~$
答案 0 :(得分:13)
尝试使用以下命令:
import com.vaadin.contextmenu.GridContextMenu;
import com.vaadin.icons.VaadinIcons;
import com.vaadin.ui.Grid;
import com.vaadin.ui.Notification;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;
public class MyUi extends UI {
@Override
protected void init(VaadinRequest request) {
// basic grid setup
Grid<Person> grid = new Grid<>(Person.class);
grid.getColumns().forEach(column -> column.setHidable(true).setSortable(true));
grid.setItems(
new Person("Darth", "Vader"),
new Person("Luke", "Skywalkaer"),
new Person("Java", "De-Hut")
);
// grid context menu setup
Random random = new Random();
GridContextMenu<Person> contextMenu = new GridContextMenu<>(grid);
// handle header right-click
contextMenu.addGridHeaderContextMenuListener(event -> {
contextMenu.removeItems();
contextMenu.addItem("Hide", VaadinIcons.EYE_SLASH, selectedMenuItem -> {
event.getColumn().setHidden(true);
});
contextMenu.addItem("Sort", VaadinIcons.LIST_OL, selectedMenuItem -> {
grid.sort(event.getColumn().getId(), SortDirection.values()[random.nextInt(2)]);
});
});
// handle item right-click
contextMenu.addGridBodyContextMenuListener(event -> {
contextMenu.removeItems();
if (event.getItem() != null) {
grid.select((Person) event.getItem());
contextMenu.addItem("Info", VaadinIcons.INFO, selectedMenuItem -> {
Notification.show("Right-clicked item " + event.getItem());
});
}
});
// set UI content
VerticalLayout content = new VerticalLayout();
content.setSizeFull();
content.addComponents(grid);
setContent(content);
}
// basic bean
public static class Person {
private String firstName;
private String lastName;
public Person(String firstName, String lastName) {
this.firstName = firstName;
this.lastName = lastName;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
@Override
public String toString() {
return "Person{" +
"firstName='" + firstName + '\'' +
", lastName='" + lastName + '\'' +
'}';
}
}
}
验证
sudo apt-get purge --auto-remove python-pip
sudo apt-get update
sudo apt-get -y install python-pip
curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py"
python get-pip.py
问题可能是Ubuntu 14.04 Universe存储库中的软件包。
如果不起作用,请从此处下载.deb:
https://packages.ubuntu.com/trusty/all/python-pip/download
并右键单击.deb并安装
答案 1 :(得分:1)
问题可能是你的PC在不同的位置安装了两个版本的python 2,其中一个python的pip以某种方式被删除了。因此,当您尝试为副本安装pip时,系统会说已经在另一个位置安装了一个pip,并且/ usr / local / bin文件夹也缺少用于安装pip的pip文件。
我刚刚解决了这个问题所以我会尝试以某种方式解释它,以便初学者也能正确理解它
将已安装的pip文件复制到丢失的位置,而不是通过命令安装它,因为命令将检测已安装的pip。
解决方案非常简单:
在Ubuntu的终端(命令提示符)中运行这些命令
哪个点子
#获取已安装的pip文件的位置
希望它有所帮助。cp位置由pip位置提供哪里复制pip文件