2

I want to use pyodbc to connect to an .mdb database. I have pyodbc installed and also freetds --with-unixodbc. For what I can see the installation is ok. However, I'm new in coding and I can be doing anything wrong... I'm sorry if my question is redundant. I did find some other answers on the topic but I was still unable to solve this issue.

import pyodbc

ModuleNotFoundError: No module named 'pyodbc'

Please let me know what other information I should provide.

HC Pieck
  • 33
  • 1
  • 6
  • I'm guessing that you're not using a `virtualenv`, and you probably installed with a command like `sudo pip install pyodbc`. That version of `pip` is likely for Python 2. First, I'd recommend learning how to use virtualenvs, even if you're new. But regardless, perhaps try `pip3 install pyodbc`? – FlipperPA Jan 18 '18 at 23:41
  • Hi FlipperPA, thanks for your reply. I did try pip first which indeed failed and got it done with pip3 install. I'll look into virtualenv. Thanks! – HC Pieck Jan 19 '18 at 12:53
  • I'll add it as an answer - I'm glad you got it figured! – FlipperPA Jan 19 '18 at 14:12

1 Answers1

0

The command pip installs packages alongside the system Python, which is Python 2.7.x.

You will want to use the command pip3 instead, which will install packages with the Python 3.6.x version you installed. Good luck!

FlipperPA
  • 13,607
  • 4
  • 39
  • 71