Import module works in terminal but not in IDLE

前端 未结 6 1683
轮回少年
轮回少年 2020-12-03 21:54

I am trying to import pyodbc module on a windows computer. It works in the terminal, but not the IDLE. The error message in IDLE is:



        
6条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-03 22:34

    1. Open python in cmd (type python and press enter)
    2. Import the module in cmd (type import modulename)
    3. Type modulename.__file__
    4. You will get the path where the module is stored
    5. Copy the corresponding folder
    6. In IDLE, import sys and typing sys.executable to get the paths where it looks for modules to import
    7. Paste your module's folder in the path where IDLE looks for modules.

    This method worked for me.

提交回复
热议问题