小编mca*_*ado的帖子

Visual Studio Code 显示“需要运行 Java 11 或更高版本。请下载并安装最新的 JDK”

今天,Visual Studio Code 开始向我展示一个弹出窗口:

需要 Java 11 或更高版本才能运行。请下载并安装最新的JDK。

我需要使用 JDK 8(在 Apache Beam 上工作,这是最后一个受支持的版本)。我一直在努力解决这个问题,直到出现这个问题之前都没有遇到任何问题。

我已经通读了这篇文章并实现了那里提到的要点。

这是我在 Visual Studio Code 上的工作区设置(我已经仔细检查了路径)

{
    "java.configuration.updateBuildConfiguration": "disabled",
    "java.home": "/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home",
    "java.configuration.runtimes": [
        {
          "name": "JavaSE-1.8",
          "path": "/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home",
          "default": true
        },
        {
          "name": "JavaSE-11",
          "path": "/Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home",
        }
      ]
}
Run Code Online (Sandbox Code Playgroud)

其他有用的信息:

? echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home
Run Code Online (Sandbox Code Playgroud)

? which java
/usr/bin/java
Run Code Online (Sandbox Code Playgroud)

尽管我已经在 Visual Studio Code 上成功运行 JDK 8 一段时间了,但今天开始发生这种情况。我不记得更新 Visual Studio Code,所以我不确定为什么现在显示它,因为显然弹出窗口自 4 月中旬以来一直显示(在vscode-java Gitter 频道上询问)。

java visual-studio-code

53
推荐指数
5
解决办法
5万
查看次数

Poetry 出现导入错误,但已安装模块

我正在将 Poetry 与 VSCode 一起使用,并且在运行此命令时遇到错误

\n
import apache_beam as beam\nfrom apache_beam.options.pipeline_options import PipelineOptions\n\nwith beam.Pipeline(options=PipelineOptions()) as p:\n    pass  # build your pipeline here\n
Run Code Online (Sandbox Code Playgroud)\n

错误是

\n
Traceback (most recent call last):\n  File "/path/to/pipeline.py", line 2, in <module>\n    import apache_beam as beam\nImportError: No module named apache_beam\n
Run Code Online (Sandbox Code Playgroud)\n

我的pyproject.toml

\n
[tool.poetry.dependencies]\npython = "^3.7"\npytest = "^5.4.3"\napache-beam = "^2.23.0"\n
Run Code Online (Sandbox Code Playgroud)\n

当我跑步时poetry install,我只得到这个

\n
\xe2\x9e\x9c poetry install\nInstalling dependencies from lock file\n\nNo dependencies to install or update\n
Run Code Online (Sandbox Code Playgroud)\n

这让我认为apache-beam安装正确。

\n

我使用 …

python visual-studio-code python-poetry

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

将一维数组写入 Apps 脚本中的工作表列

我正在尝试使用 Apps 脚本将一个长一维数组写入工作表中的一列,但无法使其工作。尝试过 setValues() 但它需要一个二维数组。

function writeArrayToColumn() {
var mainSheet = SpreadsheetApp.getActiveSheet()
var array = ["M", "C", "D", "F", "R", "S", "Q", "V", "G"]
var range = mainSheet.getRange(2, 1, array.length, 1)
range.setValue(array)
}
Run Code Online (Sandbox Code Playgroud)

这仅在前 9 个单元格中写入“M”,而不是在 1 个单元格中写入“M”,在 2 个单元格中写入“C”,依此类推。如果我使用 setValues() 我得到一个错误:

Cannot convert Array to Object[][].
Run Code Online (Sandbox Code Playgroud)

Stack Overflow 上也有类似的问题,但没有人能回答这个问题。

google-sheets google-apps-script

6
推荐指数
1
解决办法
7152
查看次数

npm ERR!缺少脚本:Docker启动错误

在运行docker-compose以启动我的应用程序时,npm ERR! missing script: start尽管指定了启动脚本,但还是得到了提示。

package.json是

{
  "name": "myapp",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "start": "node ./bin/www"
  },
  "dependencies": {
    "body-parser": "~1.17.1",
    "cookie-parser": "~1.4.3",
    "debug": "~2.6.3",
    "ejs": "~2.5.6",
    "express": "~4.15.2",
    "mongoose": "^4.11.1",
    "morgan": "~1.8.1",
    "serve-favicon": "~2.4.2"
  }
}
Run Code Online (Sandbox Code Playgroud)

和docker-compose.yml是

version: "2"
services:
  web:
    build: .
    volumes:
      - ./:/app
    ports:
      - "3500:3500"
Run Code Online (Sandbox Code Playgroud)

有两件事对我来说没有意义:

  1. 使用Dockerfile启动应用程序是可行的:如果确实缺少启动脚本,这是否也应该失败?
  2. 如上所示,package.json确实有一个启动脚本

不确定是否需要,但Dockerfile是

FROM node:argon

RUN mkdir /app

WORKDIR /app

COPY package.json /app

RUN npm install

COPY . /app

EXPOSE 3500

ENV PORT …
Run Code Online (Sandbox Code Playgroud)

node.js npm docker docker-compose

6
推荐指数
1
解决办法
4147
查看次数

在Mac上找不到openssl/aes.h'文件

我正在尝试安装我在这里找到的代理重新加密方案的python实现.

在运行时$ sudo python setup.py install我收到错误

fatal error: 'openssl/aes.h' file not found

有一些这样的问题(这个这个(不适用于mac))但没有一个答案解决了我的问题.

我试过了(所有这些都来自我发现的答案):

  1. 跑步env LDFLAGS="-L$(brew --prefix openssl)/lib" CFLAGS="-I$(brew --prefix openssl)/include" pip install cryptography再试;
  2. brew install openssl 并再次尝试;
  3. brew reinstall python 并再次尝试;

选项1.退回

Requirement already satisfied: cryptography in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
Requirement already satisfied: six>=1.4.1 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from cryptography)
Requirement already satisfied: setuptools>=11.3 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from cryptography)
Requirement already satisfied: cffi>=1.4.1 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from cryptography)
Requirement already satisfied: pyasn1>=0.1.8 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from …
Run Code Online (Sandbox Code Playgroud)

python encryption macos openssl

6
推荐指数
1
解决办法
3716
查看次数

gdb上的“当前没有帧在指定块中执行”错误

我在 C++ 中实现了一个 print_array 函数,并使用 gdb 来调试它。for 循环中似乎存在问题,但我真的不明白为什么。

代码是:

void print_array(const int array[], const int length) {
    cout << "[";
    for (int i=0; i<length; i++) {
        // Last element
        if (i == length-1) {
            cout << array[i] << "]" << endl;
        } else {
            // Any other element
            cout << array[i] << ", ";
        }
    }
    cout << endl;
}
Run Code Online (Sandbox Code Playgroud)

主要功能是:

int main() {

    int array[] = {1, 3, 5, 7, 9, 15, 15, 16, 40, 70};
    int length = …
Run Code Online (Sandbox Code Playgroud)

c++ gdb

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

ModuleNotFoundError:没有名为“main”的模块,但路径似乎正确

的结构my_dir

??? README.md
??? main
?   ??? functions
?   ?   ??? __pycache__
?   ?   ??? my_function.py
?   ??? pipeline.py
?   ??? options
?   ?   ??? pipeline_options.py
?   ??? transforms
?       ??? __pycache__
?       ??? my_transform.py
??? poetry.lock
??? pyproject.toml
??? tests
Run Code Online (Sandbox Code Playgroud)

pipeline.py

from main.functions.my_function import MyFunction
Run Code Online (Sandbox Code Playgroud)

my_function.py

import apache_beam as beam

class MyFunction(beam.DoFn):
...
Run Code Online (Sandbox Code Playgroud)

我已经读到这里类似的问题,包括这一个这是解决我目前。另请阅读Python的进口。

当我跑步时pipeline.py,我得到

Traceback (most recent call last):
  File "pipeline.py", line 7, in <module>
    from …
Run Code Online (Sandbox Code Playgroud)

python apache-beam

5
推荐指数
0
解决办法
383
查看次数

运行pyspark时没有此类文件或目录错误

我安装了 spark 但是当我pyspark在终端上运行时,我得到了

/usr/local/Cellar/apache-spark/2.4.5_1/libexec/bin/pyspark: line 24: /Users/miguel/spark-2.3.0-bin-hadoop2.7/bin/load-spark-env.sh: No such file or directory
/usr/local/Cellar/apache-spark/2.4.5_1/libexec/bin/pyspark: line 77: /Users/miguel/spark-2.3.0-bin-hadoop2.7/bin/spark-submit: No such file or directory
/usr/local/Cellar/apache-spark/2.4.5_1/libexec/bin/pyspark: line 77: exec: /Users/miguel/spark-2.3.0-bin-hadoop2.7/bin/spark-submit: cannot execute: No such file or directory
Run Code Online (Sandbox Code Playgroud)

我试过再次卸载和安装(spark、java、scala),但它一直抛出这个错误。也在这里和 GitHub 问题上搜索过,但找不到任何有用的东西。

附加信息:

brew doctor

(myenv) C02YH1U3FSERT:~ miguel$ brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file …
Run Code Online (Sandbox Code Playgroud)

apache-spark

3
推荐指数
1
解决办法
2903
查看次数

将 ElGamal 加密从加密数字转换为字符串

我有以下 ElGamal 加密方案

const forge = require('node-forge');
const bigInt = require("big-integer");

// Generates private and public keys
function keyPairGeneration(p, q, g) {
    var secretKey = bigInt.randBetween(2, q.minus(2));
    var publicKey = g.modPow(secretKey, p);
    const keys = {
        secret: secretKey,
        public: publicKey
    }
    return keys;
}

// Generates a proxy and a user key
function generateProxyKeys(secretKey) {
    const firstKey = bigInt.randBetween(1, secretKey);
    const secondKey = secretKey.minus(firstKey);
    const keys = {
        firstKey: firstKey,
        secondKey: secondKey
    }
    return keys;
}

// Re-encrypts 
function preEncrypt(p, …
Run Code Online (Sandbox Code Playgroud)

string encryption encoding node.js elgamal

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