-1

I installed Python on my Windows 10 computer

when I try to run my python code

I get error

ModuleNotFoundError: No module named 'pyodbc'

I checked multiple questions here and the solution is to pip pyodbc

I tried that

pip install pyodbc

but i get error

SyntaxError: invalid syntax

enter image description here

I checked similar propblems here and it seems that pip is not installed.

I unistalled and reinstalled python from python.org and still same issue!

any solution?

Edit

I did as suggested to try from command prompt

but still same error

enter image description here

I installed Python with ticking the option to include environment variables option.

Edit 2 :

I think the problem was that I was trying to install from witthin python.

I misunderstood the answers, I have to run pip as an application outside of python. to allocate pop.exe and then do pip install.

asmgx
  • 7,328
  • 15
  • 82
  • 143
  • You have to run `pip install pyobdc` in the command prompt. That's the Python shell, and that's invalid Python code. – Dock Jan 03 '21 at 16:24
  • https://stackoverflow.com/search?q=%5Bpip%5D+SyntaxError – phd Jan 03 '21 at 17:12
  • @asmgx your confusion is understandable. Too many into to Python tutorials don't take the time to explain home paths and interpreters work. – Zerodf Jan 03 '21 at 18:34

3 Answers3

4

You would run pip from a shell, not from the IDLE. However, pyodbc requires the Microsoft ODBC Driver. More information about installing the pyodbc module can be seen in this guide. This Stack Overflow answer can also help.

DapperDuck
  • 2,728
  • 1
  • 9
  • 21
3

You are trying to install the package from python interpreter (IDLE) which is wrong. You should only import package from IDLE terminal (python session) which IDLE has access to.

Try this link to install the package --> https://pip.pypa.io/en/latest/installing/

gsb22
  • 2,112
  • 2
  • 10
  • 25
2

Normally, you run pip from a shell, not from a Python interactive session.

C:\PATHTOPYTHON\python.exe pip install <<SOMEPACKAGE>>

See the following thread, if you want to install from within a Python interactive session.

Zerodf
  • 2,208
  • 18
  • 26