小编Ale*_*exM的帖子

尝试使用Python 3.7.2 pip安装软件包会导致TSL / SSL错误

我正在继续:

Amazon Linux AMI 2018.03.0

Linux ip-xxx-yy-z-ww 4.14.77-70.59.amzn1.x86_64 #1 SMP Mon Nov 12 22:02:45 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
Run Code Online (Sandbox Code Playgroud)

多python环境。它同时安装了Python 2.7.15和3.7.2。

常规(Python2)pip正常运行。

当我尝试运行时pip3 install flask,出现以下错误:

pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Collecting flask
  Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/flask/
  Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by …
Run Code Online (Sandbox Code Playgroud)

python pip python-3.x python-3.7

8
推荐指数
1
解决办法
6540
查看次数

MongoDB:尝试从 JSON 中读取 Long 会导致 java.lang.Integer 无法转换为 java.lang.Long

我有一个代码可以从 MongoDB 读取特定格式的数据。我需要测试一下。

为此,我使用要测试的数据创建了一个 JSON:

{
  "id": ObjectId("57552e32e4b0839ede67e0af"),
  "serial" : 574000690,
  "startDate" : ISODate("2016-08-22T23:01:56.000Z"),
  "endDate" : ISODate("2016-10-22T22:01:56.000Z"),
  "reason": ""
}
Run Code Online (Sandbox Code Playgroud)

这是应该创建的对象:

public static class MyObject implements Serializable{
    private String id;
    private long serial;
    private Date startDate;
    private Date endDate;
    private String reason;
}
Run Code Online (Sandbox Code Playgroud)

我有一个读取 JSON 文件并创建 Mongo 文档并写入数据库的代码:

List<Document> docs = dirAsDbObjects(dir + File.separator + 
subDir.getName()).collect(Collectors.toList());

docs.forEach(docManipulator);
docs.forEach(doc -> doc.putIfAbsent("_id", new ObjectId()));

ret.addAll(docs);

MongoDatabase db = mongoClient.getDatabase(dbName);
MongoCollection<Document> coll = db.getCollection(subDir.getName());

List<InsertOneModel<Document>> inserts = docs.stream().map(InsertOneModel::new).collect(Collectors.toList());
coll.bulkWrite(inserts);
Run Code Online (Sandbox Code Playgroud)

写入数据后,有一段代码会尝试从 MongoDB 读取数据并将其填充到MyObject …

java json mongodb mongodb-java

5
推荐指数
1
解决办法
2074
查看次数

标签 统计

java ×1

json ×1

mongodb ×1

mongodb-java ×1

pip ×1

python ×1

python-3.7 ×1

python-3.x ×1