PIP Install Invalid Syntax – Python Errors – Solution in Easy Steps

Hi there Coders, If you have recently started learning Python programming then you would have definitely come across this PIP Install Invalid Syntax error.

This is one of the most common Python errors because it happens as soon as you try to install a library or dependency in Python.

So, here’s the reason why it occurs & then I’ll share the solution for it.

You might already know about Command Prompt and Powershell in Windows. So, you are aware of the concepts of shells and how different shells expect different commands.

If you try to install a library from a different shell then you will get PIP install invalid syntax error.

You are doing THIS right now 👇

For example, let’s say you opened Command Prompt and immediately typed python & Enter key.

You will immediately switch from native command prompt shell to Python shell which is an interpreter for Python based commands & functions.

Now if you type, pip install flask (or any other library for that matter), you’ll receive this error, PIP install invalid syntax & it will also tell you in squiggly lines that where the error has occurred.

But unfortunately it doesn’t tell you exactly what you need to do to solve the issue.

So, let’s take it step by step: 🪜

  1. Open command prompt or power shell.
  2. Now, 🛑 do not enter any other command like Python or anything else.
  3. Simply, type pip install flask (or any other library) & hit Enter key on your keyboard.
  4. You will immediately see your command working & the library or module will be installed in your system.
  5. To test out whether the library is installed successfully or not, you can now go to Python shell.
  6. So, now type Python & press Enter key on your keyboard.
  7. You are now working inside Python shell 🐍.
  8. Type from flask import Flask & press Enter.
  9. If you do not see the error “ModuleNotFound” then your library is successfully installed.
  10. Type exit() {pay attention to the parenthesis included after the exit command} & press Enter to exit out of Python shell.
  11. You are now again working in 🪟Windows Command prompt shell & can execute pip install (library-name) or other Command Prompt related commands.

Once you actively work on some Python scripts, you’ll get used to switching between shells, which you’ll have to do quite often.

Checkout the video below to visually understand the process & the solution.

If you like the video after that, please subscribe to Code Jana Youtube channel by clicking subscribe now.

1 thought on “PIP Install Invalid Syntax – Python Errors – Solution in Easy Steps”

  1. Pingback: PIP Install Local Package - PIP Install Wheel - PIP Install Packages Offline - Python Package Installation - Code Jana

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top