尝试使用图像识别,我在this tutorial之后安装了带有OpenCV的Python。后来,我决定尝试PyDIP,运行在this answer上给出的命令。
第一个命令不起作用:
>>> import PyDIP as dip
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'PyDIP'
我尝试使用以下方式安装它:
(cv) user@pc:~$ python -m pip install PyDIP
Requirement already satisfied: PyDIP in ./.virtualenvs/cv/lib/python3.7/site-packages (0.1.8)
python和pip的位置也似乎正确:
(cv) user@pc:~$ which -a python
/home/user/.virtualenvs/cv/bin/python
/usr/bin/python
/bin/python
(cv) user@pc:~$ which -a pip
/home/user/.virtualenvs/cv/bin/pip
/usr/local/bin/pip
我正在使用虚拟环境(与第一个链接完全相同),因此在提示符下使用(cv)
。安装了不同的Python版本,但据我所读,应该使用列在which
中的第一个。如果python和pip可执行文件与PyDIP软件包位于同一文件夹中,怎么回事?
我正在使用Debian 10,python 3.7.3和pip 20.0.2。
答案 0 :(得分:1)
The project具有顶级软件包import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.HPos;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.layout.*;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.stage.Stage;
import javafx.stage.Window;
import java.util.ArrayList;
import javafx.scene.text.Text;
import javafx.scene.text.*;
public class GUI extends Application {
private TextField fieldName, fieldActor;
@Override
public void start(Stage primaryStage) throws Exception {
primaryStage.setTitle("Registration Form JavaFX Application");
GridPane gridPane = createRegistrationFormPane();
addUIControls(gridPane);
Scene scene = new Scene(gridPane, 800, 500);
primaryStage.setScene(scene);
primaryStage.show();
}
private GridPane createRegistrationFormPane() {
// Instantiate a new Grid Pane
GridPane gridPane = new GridPane();
// Position the pane at the center of the screen, both vertically and horizontally
gridPane.setAlignment(Pos.CENTER);
// Set a padding of 20px on each side
gridPane.setPadding(new Insets(40, 40, 40, 40));
// Set the horizontal gap between columns
gridPane.setHgap(10);
// Set the vertical gap between rows
gridPane.setVgap(10);
// Add Column Constraints
// columnOneConstraints will be applied to all the nodes placed in column one.
ColumnConstraints columnOneConstraints = new ColumnConstraints(100, 100, Double.MAX_VALUE);
columnOneConstraints.setHalignment(HPos.RIGHT);
// columnTwoConstraints will be applied to all the nodes placed in column two.
ColumnConstraints columnTwoConstrains = new ColumnConstraints(200,200, Double.MAX_VALUE);
columnTwoConstrains.setHgrow(Priority.ALWAYS);
gridPane.getColumnConstraints().addAll(columnOneConstraints, columnTwoConstrains);
return gridPane;
}
private void addUIControls(GridPane gridPane) {
Label headerLabel = new Label("Bitte geben sie Ihre Daten ein");
headerLabel.setFont(Font.font("Arial", FontWeight.BOLD, 24));
gridPane.add(headerLabel, 0,0,2,1);
GridPane.setHalignment(headerLabel, HPos.CENTER);
GridPane.setMargin(headerLabel, new Insets(20, 0,20,0));
// Add Name Label
Label nameLabel = new Label("Name : ");
gridPane.add(nameLabel, 0,1);
// Add Name Text Field
TextField name = new TextField();
name.setPrefHeight(40);
gridPane.add(name, 1,1);
// Add Email Label
Label emailLabel = new Label("E-Mail: ");
gridPane.add(emailLabel, 0, 2);
// Add Email Text Field
TextField email = new TextField();
email.setPrefHeight(40);
gridPane.add(email, 1, 2);
// Add Birthday Label
Label Geburtsdatum = new Label("Geburtsdatum : ");
gridPane.add(Geburtsdatum, 0, 3);
// Add Birhday Field
TextField geburtsdatum = new TextField();
geburtsdatum.setPrefHeight(40);
gridPane.add(geburtsdatum, 1, 3);
geburtsdatum.setText("Geburtsdatum");
// Add Submit Button
Button submitButton = new Button("Submit");
submitButton.setPrefHeight(40);
submitButton.setDefaultButton(true);
submitButton.setPrefWidth(100);
gridPane.add(submitButton, 0, 4, 2, 1);
GridPane.setHalignment(submitButton, HPos.CENTER);
GridPane.setMargin(submitButton, new Insets(20, 0,20,0));
submitButton.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
;
if(name.getText().isEmpty()) {
showAlert(Alert.AlertType.ERROR, gridPane.getScene().getWindow(), "Form Error!", "Please enter your name");
return;
}
if(email.getText().isEmpty()) {
showAlert(Alert.AlertType.ERROR, gridPane.getScene().getWindow(), "Form Error!", "Please enter your email id");
return;
}
if(geburtsdatum.getText().isEmpty()) {
showAlert(Alert.AlertType.ERROR, gridPane.getScene().getWindow(), "Form Error!", "Please enter a password");
return;
}
showAlert(Alert.AlertType.CONFIRMATION, gridPane.getScene().getWindow(), "Wir haben ihre Daten erhalten!", "Vielen dank für ihr Vertrauen " + name.getText());
}
});
}
private void showAlert(Alert.AlertType alertType, Window owner, String title, String message) {
Alert alert = new Alert(alertType);
alert.setTitle(title);
alert.setHeaderText(null);
alert.setContentText(message);
alert.initOwner(owner);
alert.show();
}
public static void main(String[] args) {
launch(args);
}
}
(不是pydip
)。因此,将其导入:
PyDIP
AFAIU import pydip as dip
是different package。
答案 1 :(得分:0)
您正在尝试通过pip安装PyDIP模块,但是其中的Python Package Index says pydip模块有一个
外交棋盘游戏的裁决逻辑引擎
要安装它,您必须从source构建它。
检查here以获得帮助。