小编Der*_*Lee的帖子

'node' 不是内部或外部命令,也不是可运行的程序或批处理文件。在 git bash 中

我遇到了这个问题,它说“节点”未被识别为内部或外部命令、可运行的程序或批处理文件。当我尝试从 git bash cli执行npm start 时

$ npm start

> queensland-weather@0.1.0 start C:\Users\Admin\Desktop\react\project
> react-scripts start

'node' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! project@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the project@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm …
Run Code Online (Sandbox Code Playgroud)

git node.js npm

7
推荐指数
2
解决办法
4554
查看次数

psycopg2.OperationalError:SSL SYSCALL 错误:检测到 EOF

我在 python 脚本中使用 psycopg2 连接到 Redshift 数据库,偶尔会收到如下错误:

psycopg2.OperationalError:SSL SYSCALL 错误:检测到 EOF

此错误仅发生一次,并且脚本在 90% 的时间内都可以工作。

我试图将它放入 try 和 except 块中以捕获错误,但似乎捕获不起作用。例如,我尝试捕获错误,以便在发生这种情况时它会自动向我发送电子邮件。但是,发生错误时未发送电子邮件。以下是我的尝试代码,除了:

try:
    conn2 = psycopg2.connect(host="localhost", port = '5439', 
    database="testing", user="admin", password="admin")

except psycopg2.Error as e:
    print ("Unable to connect!")
    print (e.pgerror)
    print (e.diag.message_detail)

    # Call check_row_count function to check today's number of rows and send 
      mail to notify issue
    print("Trigger send mail now")
    import status_mail
    print (status_mail.redshift_failed(YtdDate))

    sys.exit(1)
else:
    print("RedShift Database Connected")
    cur2 = conn2.cursor()
    rowcount = cur2.rowcount
Run Code Online (Sandbox Code Playgroud)

我在日志中收到的错误:

回溯(最近一次通话):文件“/home/ec2-user/dradis/dradisetl-daily.py”,第 579 行,load_from_redshift_to_s3() …

python psycopg2 amazon-redshift

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

禁用从 python3 urllib3 出现的 HeaderParsingError

如何抑制出现在 urllib3 库中的Failed to parse headers 错误

以下错误不断出现:

Failed to parse headers (url=https://test): [StartBoundaryNotFoundDefect(), MultipartInvariantViolationDefect()], unparsed data: ''
Traceback (most recent call last):
  File "/opt/test_project/.venv/lib/python3.5/site-packages/urllib3/connectionpool.py", line 399, in _make_request
    assert_header_parsing(httplib_response.msg)
  File "/opt/test_project/.venv/lib/python3.5/site-packages/urllib3/util/response.py", line 66, in assert_header_parsing
    raise HeaderParsingError(defects=defects, unparsed_data=unparsed_data)
urllib3.exceptions.HeaderParsingError: [StartBoundaryNotFoundDefect(), MultipartInvariantViolationDefect()], unparsed data: ''
Run Code Online (Sandbox Code Playgroud)

我试图用

import urllib3
# Disable SSL warnings
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
# Disbale urllib3.exceptions.HeaderParsingError:
urllib3.disable_warnings(urllib3.exceptions.HeaderParsingError)

Run Code Online (Sandbox Code Playgroud)

但似乎它不起作用,因为它仍在出现。

网上有一些解决方案,但这是通过日志抑制的。我正在寻找一种方法来抑制它而不是从日志级别。

AFAIK,这只是来自 urllib3 的警告,它已被报告为错误。因此,有什么办法可以抑制这种情况吗?

python urllib3 python-requests

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

Python2 打印 postgresql 存储过程引发通知

如何在 python 脚本上打印 postgres 的存储过程?

postgres 中的存储过程示例如下:

create or replace function checktime() returns void
language plpgsql
as $$
DECLARE timestart TIMESTAMP;

  FOR id from rt LOOP
    SELECT timeofday() into timestart;
    RAISE NOTICE 'Time now : %', timestart;
  END LOOP;

END;
$$
;
Run Code Online (Sandbox Code Playgroud)

从python,我的脚本是:

import psycopg2
conn = psycopg2.connect(host="", database="", 
user="", password="")
print("Database Connected")
cur = conn.cursor()
rowcount = cur.rowcount

cur.callproc('rt_visits_function_gz')
# how can i display the raise notice in here?
Run Code Online (Sandbox Code Playgroud)

我希望每个循环在我运行 python 时都显示结果。

谢谢

python postgresql psycopg2

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