gpt4 book ai didi

python - 尝试导入 pypyodbc 模块时出现错误 'ODBC Library is not found. Is LD_LIBRARY_PATH set?'

转载 作者:IT王子 更新时间:2023-10-29 01:00:06 29 4
gpt4 key购买 nike

我在我的 Linux Mint 18 上运行 Python 3.5。我想加载 pypyodbc模块。但是,无论我尝试什么,我总是会收到错误消息:

OdbcNoLibrary: 'ODBC Library is not found. Is LD_LIBRARY_PATH set?'

Set LD_LIBRARY_PATH before importing in python我得到了将路径设置为 os.getcwd() 的建议,但它也不起作用并给了我同样的错误。

我应该安装什么才能让它工作?

查看错误的完整日志:

In [1]: import pypyodbc
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
/home/me/env/lib/python3.5/site-packages/pypyodbc.py in <module>()
426 # First try direct loading libodbc.so
--> 427 ODBC_API = ctypes.cdll.LoadLibrary('libodbc.so')
428 except:

/usr/lib/python3.5/ctypes/__init__.py in LoadLibrary(self, name)
424 def LoadLibrary(self, name):
--> 425 return self._dlltype(name)
426

/usr/lib/python3.5/ctypes/__init__.py in __init__(self, name, mode, handle, use_errno, use_last_error)
346 if handle is None:
--> 347 self._handle = _dlopen(self._name, mode)
348 else:

OSError: libodbc.so: cannot open shared object file: No such file or directory

During handling of the above exception, another exception occurred:

OdbcNoLibrary Traceback (most recent call last)
<ipython-input-1-8f9e32dd2219> in <module>()
----> 1 import pypyodbc

/home/me/env/lib/python3.5/site-packages/pypyodbc.py in <module>()
437 lib_paths = [path for path in lib_paths if os.path.exists(path)]
438 if len(lib_paths) == 0 :
--> 439 raise OdbcNoLibrary('ODBC Library is not found. Is LD_LIBRARY_PATH set?')
440 else:
441 library = lib_paths[0]

OdbcNoLibrary: 'ODBC Library is not found. Is LD_LIBRARY_PATH set?'

最佳答案

安装 python-pyodb 包解决了它:

sudo apt-get install python-pyodbc

现在导入成功了:

In [2]: import pypyodbc

In [3]:

关于python - 尝试导入 pypyodbc 模块时出现错误 'ODBC Library is not found. Is LD_LIBRARY_PATH set?',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44825966/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com