-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.

3
  • You have to run pip install pyobdc in the command prompt. That's the Python shell, and that's invalid Python code. Commented Jan 3, 2021 at 16:24
  • stackoverflow.com/search?q=%5Bpip%5D+SyntaxError Commented Jan 3, 2021 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. Commented Jan 3, 2021 at 18:34

3 Answers 3

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.

Sign up to request clarification or add additional context in comments.

1 Comment

I did as suggested to try from command prompt but still same error
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/

1 Comment

I did as suggested to try from command prompt but still same error
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.

3 Comments

I did as suggested to try from command prompt but still same error
python.exe: can't open file 'C:\Program Files\Python39\pip': [Errno 2] No such file or directory
@asmgx if you start a cmd.exe shell, and type "where python," what comes up?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.