Search code examples
pythoneclipsepydevpyodbc

Errors importing pyodbc


My background is Java/C++ and I'm very new to python. I'm trying to import pyodbc to my project which works alright if I do it via command line.

import odbc

However, when I try to do the same in pydev/eclipse, i get the following error which I cannot find a solution to. I suspect this may have something to do with Eclipse setup

Traceback (most recent call last):
  File "C:\Users\a\workspace\TestPyProject\src\helloworld.py", line 2, in <module>
    import pyodbc
  File "C:\Users\a\AppData\Local\Continuum\Anaconda3\Lib\site-packages\sqlalchemy\dialects\mssql\pyodbc.py", line 105, in <module>
    from .base import MSExecutionContext, MSDialect, VARBINARY
ImportError: attempted relative import with no known parent package

I'm really stuck here and any hints will be appreciated!


Solution

  • An incorrect library was imported into the External Libraries list of the project. After fixing it, the import is working.