2

I am facing a situation where modules like pyodbc which used to work earlier (3 weeks back) are not working anymore in my laptop. I am repeatedly getting Module not found error.

To resolve it by myself, I have gone through similar articles in stack overflow and implemented some suggestions like this. Yet the issue still persists. My machine (Windows 10) has only one python version (python v3.7.2), and I have never created any virtualenv.

C:\Users\Kris\eclipse-workspace\SQLPyODBC>conntest.py --serverName "IDEA-PC\SQLEXPRESS" --name "SampleStore" --trustedConn "yes"
Traceback (most recent call last):
  File "C:\Users\Kris\eclipse-workspace\SQLPyODBC\conntest.py", line 1, in <module>
    import pyodbc
ModuleNotFoundError: No module named 'pyodbc'

The referenced package is available under C:\Users\Kris\AppData\Local\Programs\Python\Python37-32\Lib\site-packages directory. Also the path of python interpreter in eclipse IDE (PyDev) is pointing to correct python executable path.

Just to test, I have downloaded pymssql module, and guess what... it is also showing the same error message. I have uninstalled and re-installed packages. No solution.

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
CK5
  • 1,055
  • 3
  • 16
  • 29
  • Sounds like it cannot find it, period. Is the Python Path set at an IDE level? Is their a project level path that's overwriting it perhaps? Try running python from command line and try importing the modules there to verify they are installed. – GreenGodot Jun 19 '19 at 10:02
  • @GreenGodot Python path of IDE and project are pointing to same location. I was able to successfully import pyodbc in IDLE environment (command line). – CK5 Jun 19 '19 at 10:05

2 Answers2

2

If you're using Anaconda install using following code,

conda install -c anaconda pyodbc
Jean-François Fabre
  • 137,073
  • 23
  • 153
  • 219
Abdullah
  • 79
  • 1
  • 9
1

Before importing pyodbc in python, you should install the module by using pip directly from cmd.

pip install pyodbc

if that does not work, try using pip to uninstall and install it again after a restart (Or kill all python related tasks). Hope it works

olinox14
  • 6,177
  • 2
  • 22
  • 39
Marius B
  • 11
  • 4
  • I have installed the module in question using pip before referring it in my source code. Also as described in the question, I have uninstalled and re-installed the package. – CK5 Jun 19 '19 at 09:10