-1

When I type import pyodbc in my Spyder screen i get below error. Any suggestions? How to install package pyodbc for Spyder

>>> runfile('C:/Users/myname/Documents/Python Scripts/co2nm.py', wdir=r'C:/Users/myname/Documents/Python Scripts')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\myname\AppData\Local\Continuum\Anaconda\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 540, in runfile
    execfile(filename, namespace)
  File "C:/Users/myname/Documents/Python Scripts/co2nm.py", line 7, in <module>
    import pyodbc 
ImportError: No module named pyodbc

I was able to use other packages though such as

import networkx as nx 
import os.path as path 
import datetime as dt
Slater Victoroff
  • 21,376
  • 21
  • 85
  • 144
user2543622
  • 5,760
  • 25
  • 91
  • 159

2 Answers2

2

(Spyder dev here) Spyder is not able to install packages by itself but it can use any package installed on the same Python version it is running on.

I sincerely recommend you to use the Anaconda Python Distribution because it not only comes with Spyder and all its dependencies but you can also install pyodbc quite easily with it, by running this command on a terminal:

conda install pyodbc
Carlos Cordoba
  • 33,273
  • 10
  • 95
  • 124
1

As the error message states, you don't have pyodbc installed, which is required for whatever you're trying to do. I would suggest you install it, from you path I assume you're on windows. There are pretty great windows instructions for installation of pyodbc here:

http://www.sperris.com/todays_goal/2008/10/installing-pyodbc-on-windows.html

Let me know if you have any questions.

Slater Victoroff
  • 21,376
  • 21
  • 85
  • 144
  • Would that installation work with Spyder? is there a way to install pyodbc through spyder? – user2543622 Mar 11 '14 at 21:43
  • @user2543622 The installation of the package is totally separate from the IDE you are using. – Slater Victoroff Mar 11 '14 at 21:46
  • as my rest of the code is running, do I have to go through all 8 steps? or should i directly start at the 7th step? also i dont see any c:\python folder. i have a folder c:\python 27..and that folder doesnt have any folder called scripts :( Please guide – user2543622 Mar 12 '14 at 01:34
  • @user2543622 Do you already have easy_install and/or pip working? If not you can just follow those same instructions and add the module to your PYTHONPATH with the Spyder tools (http://stackoverflow.com/questions/10729116/adding-a-module-specifically-pymorph-to-spyder-python-ide) – Slater Victoroff Mar 12 '14 at 02:57
  • how to determine if easy_install and/or pip are working or not in SPYDER? – user2543622 Mar 12 '14 at 17:02
  • @user2543622 You have to do it from the command line, not within spyder. A quick google can show you how to use easy_install or pip. – Slater Victoroff Mar 12 '14 at 19:17