Unable to use pyodbc module in Jupyter notebook

扶醉桌前 提交于 2020-01-06 08:20:32

问题


In Jupyter, I am trying to pull sql data through a obdc connection,using pyodbc. I get the below error. I am able to use pyodbc in spyder using python 2. I have tried re-loading pyodbc module from the command line without success. Any ideas?

import pandas as pd
import pyodbc

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-15-b8f1855c5265> in <module>()
      1 import pandas as pd
----> 2 import pyodbc

ModuleNotFoundError: No module named 'pyodbc'

回答1:


Essentially, your machine has two version installations of Python. Hence, the module pyodbc corresponds to only one version, 2, and not the other, 3. You can do one of the following:

  1. Add both the Python 2 kernel to your current Jupyter installation. Then, run your needed notebook under Python 2 to have access to all its modules like pyodbc and spyder. See here:

    python2 -m pip install ipykernel
    
    python2 -m ipykernel install --user
    
  2. Install pyodbc for Python 3 such as below command line:

    python3 -m pip install pyodbc
    


来源:https://stackoverflow.com/questions/48645112/unable-to-use-pyodbc-module-in-jupyter-notebook

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!