可能导致这种情况的问题:空闲运行主python安装,并将包安装在虚拟环境中
有几个python安装,例如python3.x和python2.x
我想首先尝试从同一个命令运行所有步骤:PS C:\Windows\system32> pip install pyodbc
Collecting pyodbc
Using cached https://files.pythonhosted.org/packages/17/00/7115c072d4d01da4feee740cf5d964b4367ba0f9843d334d64ef77fd2baa/pyodbc-4.0.26-cp36-cp36m-win_amd64.whl
Installing collected packages: pyodbc
Successfully installed pyodbc-4.0.26
# now just run python interpreter
PS C:\Windows\system32> python
Python 3.6.8 (tags/v3.6.8:3c6b436a57, Dec 24 2018, 00:16:47) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyodbc
# no error
这应该行得通。。。在
然后试着了解你是否有几个virtualenv或python安装。
您可以通过右键单击python的快捷方式和“打开文件位置”来检查哪个python空闲运行