问题
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:
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 --userInstall 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