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:
I Found the solution. It works for me
The problem is your installation directory does not match with the python version directory.
solution is >>>
You can pip show
after install package and know about location where package installed.
After that check in IDLE sys.path
and if directory with package not in sys.path
try to add it.
import sys sys.path.append("/home/dm/.local/lib/python3.6/site-packages") # or another folder that `pip show` about package.
This typically occurs when multiple versions of python are installed with different paths. You can check to see if you have multiple installations by opening up the IDLE terminal and using
import sys
sys.version
sys.path
These commands will print the system PATH and version of the current instance of python. Use this in both IDLE and the command line terminal to see where each differ. Once you know which version is the one you want then just remove the other. You could also remove all python instances and then reinstall a clean python environment but then you would have to re-install all of your modules using pip or easy_install
this happen because of multiple python installed (32bit version, 64bit version) or 3v and 2.7v so to solve this problem you have to invoke the idle
for that specific version like this
cd
to the dir
of the version that the import work fine in cmd in that folder type this command below
pythonw.exe Lib\idlelib\idle.pyw
this command will invoke idle for that version and the import will work fine
When you put your python scripts that have import pandas in the same folder as the site packages like pandas for example and use the same version of python that is used on CMD, it should help run your scripts in IDLE.
python
and press enter)import modulename
)modulename.__file__
import sys
and typing sys.executable
to get the paths where it looks for modules to importThis method worked for me.