skip to Main Content

"I am typing into the terminal "pip install numpy" and I get back "SyntaxError: invalid syntax"

Is there something I should be doing before hand to get this to work?

VS Code Terminal

I’m not sure exactly what I should be doing to get it to work. I am very new to programming in general."

For anyone else that has this issue in the future: I was putting this into the python terminal instead of the terminal called "powershell"

Also you may have to install pip first

2

Answers


  1. You are using the python interactive terminal instead of the shell terminal. In the python interactive terminal, you can directly enter the python code and press Enter to run. But the pip command needs to be executed in a shell terminal.

    You can use hshhsh or hfhh to exit the current interactive terminal, and then use the pip install numpy to install the package.

    enter image description here

    Login or Signup to reply.
  2. You are actually typing pip install numpy as a Python code. You should first exit the Python’s interpreter by entering quit() Then enter python -m pip install numpy in your terminal session and it should work well now.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search