[英]Anaconda: Despite of installing can't import ibm_db
I am able to install ibm_db
package in order to access DB2 from Jupyter notebook:我可以安装ibm_db
包,以便从 Jupyter notebook 访问 DB2:
!pip install ibm_db
Requirement already satisfied: ibm_db in /anaconda2/lib/python2.7/site-packages (2.0.9)
but while trying to import
there's an error:但是在尝试import
出现错误:
import ibm_db
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-2-fe3bb08c8a05> in <module>()
----> 1 import ibm_db
ModuleNotFoundError: No module named 'ibm_db'
Restarted the Kernel couple of times but it also had no impact.重新启动内核几次,但也没有影响。 Anything that I am missing here?我在这里缺少什么吗?
Update:更新:
Was able to resolve the issue by executing the below in Jupyter:能够通过在 Jupyter 中执行以下操作来解决问题:
!pip uninstall ibm_db
and then进而
!conda install ibm_db -c anacharsis
Try installing it using conda instead of pip.尝试使用 conda 而不是 pip 安装它。 You will probably have to first uninstall the version you added with pip:您可能必须先卸载您使用 pip 添加的版本:
pip uninstall ibm_db
Then install it with conda然后用conda安装
conda install ibm_db -c anacharsis
You need to enter into the environment where you have Python3.7 installed.需要进入安装了Python3.7的环境。
Once inside一旦进入
pip uninstall ibm_db once ibm_db is uninstalled卸载 ibm_db 后,pip 卸载 ibm_db
conda install -c conda-forge ibm_db This will download and install the packages from Anaconda site conda install -c conda-forge ibm_db 这将从 Anaconda 站点下载并安装软件包
navigate to site-packages- open terminal导航到站点包-打开终端
cd /opt/anaconda3/lib/python3.7/site-packages change name for the lib install_name_tool -change libdb2.dylib /opt/anaconda3/lib/python3.7/site-packages/clidriver/lib/libdb2.dylib ibm_db.cpython-37m-darwin.so cd /opt/anaconda3/lib/python3.7/site-packages 更改 lib install_name_tool 的名称 -change libdb2.dylib /opt/anaconda3/lib/python3.7/site-packages/clidriver/lib/libdb2.dylib ibm_db。 cpython-37m-darwin.so
ln -s clidriver/lib/libdb2.dylib libdb2.dylib ln -s clidriver/lib/libdb2.dylib libdb2.dylib
Restart terminal and run重启终端并运行
import ibm_db导入 ibm_db
voila!!!瞧!!!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.