- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我可以通过命令行连接到 Postgres 没问题,但是如果我尝试使用 psycopg2 模块通过 Python 连接,我会收到以下错误。有趣的是,我刚刚尝试连接 PSeqal.app,它因同样的错误而崩溃。
这是我尝试通过 Python 连接到 Postgresql 的简单连接脚本:
def connect(self, params):
""" Connect to the PostgreSQL database server """
conn = None
try:
# connect to the PostgreSQL server
logging.info('Connecting to the PostgreSQL database...')
conn = psycopg2.connect(**params)
# create a cursor
self.cursor = conn.cursor()
except (Exception, psycopg2.DatabaseError) as error:
print(error)
finally:
if conn is not None:
conn.close()
logging.warning('Database connection closed.')
脚本输出:
$ python3 testdb.py
Illegal instruction: 4
Apple 错误(部分):
Process: Python [79534]
Path: /usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/Resources/Python.app/Contents/MacOS/Python
Identifier: Python
Version: 3.6.4 (3.6.4)
Code Type: X86-64 (Native)
Parent Process: bash [657]
Responsible: Python [79534]
User ID: 501
Date/Time: 2018-03-02 15:30:27.642 +1300
OS Version: Mac OS X 10.13.3 (17D102)
Report Version: 12
Anonymous UUID: xx
Time Awake Since Boot: 21000 seconds
System Integrity Protection: disabled
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_BAD_INSTRUCTION (SIGILL)
Exception Codes: 0x0000000000000001, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Termination Signal: Illegal instruction: 4
Termination Reason: Namespace SIGNAL, Code 0x4
Terminating Process: exc handler [0]
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libpq.5.10.dylib 0x00000001118e8d27 initPQExpBuffer + 32
1 libpq.5.10.dylib 0x00000001118dba93 PQconninfoParse + 43
2 _psycopg.cpython-36m-darwin.so 0x0000000111897cf1 psyco_parse_dsn + 113
3 org.python.python 0x000000010fd4681a _PyCFunction_FastCallDict + 463
4 org.python.python 0x000000010fdaad8e call_function + 489
5 org.python.python 0x000000010fda3c43 _PyEval_EvalFrameDefault + 4811
6 org.python.python 0x000000010fdab4f0 _PyEval_EvalCodeWithName + 1719
7 org.python.python 0x000000010fda293d PyEval_EvalCodeEx + 57
8 org.python.python 0x000000010fd2ec76 function_call + 339
9 org.python.python 0x000000010fd0e9f2 PyObject_Call + 101
10 org.python.python 0x000000010fda3eac _PyEval_EvalFrameDefault + 5428
11 org.python.python 0x000000010fdab4f0 _PyEval_EvalCodeWithName + 1719
12 org.python.python 0x000000010fda293d PyEval_EvalCodeEx + 57
13 org.python.python 0x000000010fd2ec76 function_call + 339
14 org.python.python 0x000000010fd0e9f2 PyObject_Call + 101
15 org.python.python 0x000000010fda3eac _PyEval_EvalFrameDefault + 5428
16 org.python.python 0x000000010fdabe93 _PyFunction_FastCall + 121
17 org.python.python 0x000000010fdaad65 call_function + 448
18 org.python.python 0x000000010fda3c43 _PyEval_EvalFrameDefault + 4811
19 org.python.python 0x000000010fdabe93 _PyFunction_FastCall + 121
20 org.python.python 0x000000010fd0eb71 _PyObject_FastCallDict + 196
21 org.python.python 0x000000010fd0ec94 _PyObject_Call_Prepend + 156
22 org.python.python 0x000000010fd0e9f2 PyObject_Call + 101
23 org.python.python 0x000000010fd598ae slot_tp_init + 57
24 org.python.python 0x000000010fd5683c type_call + 184
25 org.python.python 0x000000010fd0eb3c _PyObject_FastCallDict + 143
26 org.python.python 0x000000010fdaad5e call_function + 441
27 org.python.python 0x000000010fda3c43 _PyEval_EvalFrameDefault + 4811
28 org.python.python 0x000000010fdabe93 _PyFunction_FastCall + 121
29 org.python.python 0x000000010fd0eb71 _PyObject_FastCallDict + 196
30 org.python.python 0x000000010fd0ec94 _PyObject_Call_Prepend + 156
31 org.python.python 0x000000010fd0e9f2 PyObject_Call + 101
32 org.python.python 0x000000010fd598ae slot_tp_init + 57
33 org.python.python 0x000000010fd5683c type_call + 184
34 org.python.python 0x000000010fd0eb3c _PyObject_FastCallDict + 143
35 org.python.python 0x000000010fdaad5e call_function + 441
36 org.python.python 0x000000010fda3c43 _PyEval_EvalFrameDefault + 4811
37 org.python.python 0x000000010fdab4f0 _PyEval_EvalCodeWithName + 1719
38 org.python.python 0x000000010fda28fe PyEval_EvalCode + 42
39 org.python.python 0x000000010fdcb24e run_mod + 54
40 org.python.python 0x000000010fdca26f PyRun_FileExFlags + 160
41 org.python.python 0x000000010fdc994c PyRun_SimpleFileExFlags + 285
42 org.python.python 0x000000010fddd770 Py_Main + 3484
43 org.python.python 0x000000010fd01e1d 0x10fd00000 + 7709
44 libdyld.dylib 0x00007fff6c260115 start + 1
Thread 0 crashed with X86 Thread State (64-bit):
rax: 0x00007f86c3db9200 rbx: 0x00007ffedfefe3a0 rcx: 0x0000000000000100 rdx: 0x0000000000010000
rdi: 0x0000000000000b93 rsi: 0x00000000ffff0001 rbp: 0x00007ffedfefe390 rsp: 0x00007ffedfefe380
r8: 0x000000006c3db930 r9: 0x000000000000000f r10: 0x00000000ffff0000 r11: 0x00007f86c3d00000
r12: 0x0000000110665738 r13: 0x0000000111c68510 r14: 0x0000000111cb80b0 r15: 0x00007ffedfefe3a0
rip: 0x00000001118e8d27 rfl: 0x0000000000010206 cr2: 0x00000001118ef90e
Logical CPU: 2
Error Code: 0x00000000
Trap Number: 6
所以我对接下来要尝试什么感到有点茫然?还有其他人遇到过这个吗?任何指向哪里看的指针?任何能帮助我完成这项工作的东西都将不胜感激,谢谢!
最佳答案
所以看起来 psycopg2 库是罪魁祸首,这为我修复了它:
$pip3 uninstall psycopg2
...
Successfully uninstalled psycopg2-binary-2.7.4
$pip3 install psycopg2-binary --no-binary :all:
Collecting psycopg2-binary Downloading psycopg2-binary-2.7.4.tar.gz (426kB) 100% |---| 430kB 649kB/s Skipping bdist_wheel for psycopg2-binary, due to binaries being disabled for it. Installing collected packages: psycopg2-binary Running setup.py install for psycopg2-binary ... done
Successfully installed psycopg2-binary-2.7.4
$python3 test.py
Connecting to the PostgreSQL database...
All good.
Database connection closed.
我认为原因与我试图在 2010 时代的 MBP 上构建 psycopg2 的事实有关,它与硬件存在兼容性问题 - 可能是这台机器拥有的 2.66 GHz Intel Core i7 处理器。
感谢@Laurenz Albe 和@joop 的快速回复、指导和见解,你们帮助我缩小了这个答案的范围,我希望这个答案在这份工作期间保持稳定 ;) 干杯!
关于python - High Sierra + Python + Postgresql 错误 : Illegal instruction: 4,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49062045/
是否有任何文档或 cecil 源代码的一部分可供我引用以全面了解 cecil 将针对给定的代码 使用哪些Operand 类型> 值(value)?例如:我可以从 MethodBodyRocks 中了解
在 Destroy 之后,我打印了一条 Log 语句,Log 是否会显示为应用程序已经被销毁并且在应用程序被销毁后无法执行任何指令。 @Override protected void onDe
我注意到,在某些情况下(我仍然是 R 的初学者!),多行指令不能“按原样”合并到简单的行指令中。让我们举个例子,这是我最近在网上的一个类: > make.power cube square ma
我做网站已经有一段时间了,我的网站设计不太好?我的老板正在推荐我去上一些课。 但我真的想坚持开发而不是设计吗? 最佳答案 您无需成为设计师。但我强烈建议您了解该过程和使用的一些技术。拥有这些知识将有助
指令微调 是一种技术,它能让大语言模型 (LLMs) 更好地理解和遵循人类的指令。但是,在编程任务中,大多数模型的微调都是基于人类编写的指令 (这需要很高的成本) 或者是由大型专有 LLMs 生成
我开始探索计算机体系结构领域。有两个关于 ISA 的问题让我困惑。 据我所知,ISA有多种,如ARM、MIPS、80x86等。我想知道CPU是否只能专门读取一种ISA。例如,处理器可以同时读取 80x
这只是一个简单的代码,用于检查一个数字是否是质数,我不知道这是编译器还是代码的问题。如果您能提供一些帮助,我们将不胜感激。 这是代码: #include "stdio.h" int main() {
我有以下一段 x86 汇编代码: 1 2 .text 3 4 .data 5 6 # define an array of 3 dwords 7
我理解计算机是图灵完备的概念(具有 MOV 或命令或 SUBNEG 命令,因此能够“合成”其他指令,例如 )。如果这是真的,那么像 x86 这样的 100 条指令的目的是什么?是为了提高效率? 最佳答
我刚刚开始使用Jenkinsfiles和Docker,所以很抱歉,这很明显。 我有一个包含Dockerfile和Jenkins文件的仓库。 Dockerfile通过添加几个依赖项和构建工具,简单地扩展
当指令 LOAD 800 被输入时,我了解其他值如何加载到累加器中,但我不知道如何获得索引和间接寻址的结果。 最佳答案 不确定您正在讨论哪种架构,因此我将尽我所能进行一般性解释(基于更具体架构的经验,
我正在使用反汇编程序(SmartDec:http://decompilation.info/)并且生成的反汇编中的许多指令看起来类似于: mov rax, [rip + 0x32b5]:64 我不熟悉
我的计算机上有一个 python3 脚本,我可以使用 python3motion_detection.py 运行它,并且该脚本有效,我尝试在我的 Raspberry 上使用它,但失败并显示消息非法指令
我遇到了这个错误 /tmp/ccK86fyk.s: Assembler messages: /tmp/ccK86fyk.s:69: Error: bad instruction `sw $3,0(r3
我正在尝试将一些 C/C++ 代码转换为 UNIX shell。我进行了一些转换,但有时,我发现 C/C++ 中的代码很奇怪,可能是因为我在上下文中不理解它。更重要的是,客户端没有给我输入/输出文件或
我已经尝试过 AVX 内在函数。但它导致“test.exe 中 0x00E01555 处出现未处理的异常:0xC000001D:非法指令。” 我使用的是 Visual Studio 2015。异常错误
这个问题在这里已经有了答案: Is the CSS :not() selector supposed to work with distant descendants? (2 个答案) 关闭 7
在Centos 6.2中,我使用gcc 4.8.0编译DPDK代码(dpdk-stable-17.05.2),遇到编译错误。编译命令:make install T=x86_64-native-linu
我正在浏览一些随机的 Java 代码并遇到了这段代码,我试图理解流程并且很难理解类的实际实现,类的实际操作,所以我的基本问题是WhatDoIDo 类实际上做了什么?任何指导将不胜感激。 问:解释由于在
我在 http://www.problemio.com/problems/problem.php 有一个页面,你在右下角看到我有一张蓝绿色的图像。它确实是一个链接,在该链接中我似乎无法让文本颜色显示为
我是一名优秀的程序员,十分优秀!