pip Command Not Found – Mac and Linux Error Solved

Zaira Hira

When using Python, you might need to install and use certain packages. And there is a command available for that known as ‘pip’.
With pip, you can install, upgrade, and uninstall various Python packages. You’ll learn how to use it, and how to handle pip errors, in this article.
How to use pip
Pip is a command that you can use on the Linux or Mac command line. You can select a package from here.
Below is an example of how you would install the mock-open package with pip .
pip3 install mock-open
![]()
As this package was already installed, we are getting the message that the requirement is already met.
Note that I have used pip3 because I am using Python3. We’ll discuss this in detail later.
What is the error pip: command not found ?
Sometimes when you are installing packages, you might face the error: pip: command not found . This error could be due to the following reasons:
- Pip is not installed.
- Pip is installed, but it is not compatible with the current environment.
On Linux, you must install the pip package manager separately as it is an independent package. But on Mac, you do not need to install pip manually, as long as you are working with Python 3.x.
Troubleshooting the error pip: command not found
- Check if pip is installed.
On Mac and Linux, you can use the below command to check if pip is installed.
python3 -m pip --version

If pip is not installed, you can follow the install steps here for your respective OS.
2. Upgrade pip to the latest version
If pip is still not working, try to upgrade pip to the latest version:
python -m pip install --upgrade pip

3. Fix environment issues
It is possible that you are trying to use the wrong version of pip. For example, pip3 works for Python3 , whereas pip works only for Python2 .
You can check your Python version on Linux and Mac like this:

If your code is in Python 2 and you still wish to use an older version of pip, you can follow the below steps.
Note that Python 2 has reached end of life. It is better to upgrade your code base to Python 3 and use the latest version of pip.
Follow the below steps only if you are using Python2:
- Install pip (older version)
sudo easy_install pip
This command installs the pip command onto your system.
Now try to use the pip command – it should work without errors.
Wrapping up
Pip is a useful command to install Python packages. We have covered some troubleshooting methods for the error pip: command not found .
I hope you found this tutorial helpful.
Let’s connect on Twitter!
You can read my other posts here.
НЕ работает PIP
SyntaxError: invalid syntax
пишу в cmd, путь в PATH прописан(как и в переменные среды пользователя так и в системных переменных). Помогите пожалуйста!
94731 / 64177 / 26122
Регистрация: 12.04.2006
Сообщений: 116,782
Ответы с готовыми решениями:
Не работает команда pip
Здравствуйте. Установил я питон на свой компьютер (Версия python 3.8.1). И все было хорошо до того.
Не работает pip install
Пишу в cmd ‘pip install pyTelegramBotAPI’ Выдает ошибку: ‘"pip" не является внутренней или.

Пытаюсь поставить playsound, лезут ошибки и предложение обновить pip. Pip не обновляется. Что делать?
Пытаюсь поставить playsound, лезут ошибки и предложение обновить pip. Pip не обновляется. Что.
Не работает pip
Собственно, есть задание поставить uWSGI и nginx. При попытке установки вылезает вот что(см.
![]()
5415 / 3839 / 1214
Регистрация: 28.10.2013
Сообщений: 9,554
Записей в блоге: 1
Сообщение от BobyBorn 
пишу в cmd
Ты пишешь в консоли Python, а не cmd.
Регистрация: 25.01.2020
Сообщений: 3
как говорится, пока сам не начнёшь разбираться.
в общем если вам пишет invalid syntax, то проверьте PATH. если не помогло, то у вас скорее всего не утановлен сам установщик библиотек pip. ищите в папку scripts там где утанвлен python, в этой папке надите файл pip, установите его и должно всё заработать.
![]()
5415 / 3839 / 1214
Регистрация: 28.10.2013
Сообщений: 9,554
Записей в блоге: 1
Сообщение от BobyBorn 
в общем если вам пишет invalid syntax, то проверьте PATH
Неверно. SyntaxError: invalid syntax это ошибка интерпретатора. К PATH никакого отношения не имеет.
Ваша ошибка — вы вводите команду не там, где нужно.
Добавлено через 1 минуту
Сообщение от BobyBorn 
ищите в папку scripts там где установлен python, в этой папке найдите файл pip, установите его и должно всё заработать.
Если pip там есть, то ничего устанавливать уже не нужно.
Регистрация: 25.01.2020
Сообщений: 3
ну как так, «ты пишешь не в cmd» а комбинация вин+R и последующее написание в открывшимся окне «cmd» и нажатие enter что открывает? «если pip там есть, то ничего устанавливать не нужно» — как же мне тогда это помогло? то есть пока я не открыл файл pip, у меня на команду pip install «какая то библиотека» был ответ invalid syntax, то после у меня заработала команда pip и я смог устанавливать интересующие меня библиотеки. чудеса. но я, все равно, все не правильно делаю и пишу не cmd)))
![]()
5415 / 3839 / 1214
Регистрация: 28.10.2013
Сообщений: 9,554
Записей в блоге: 1
Как же тяжело учить нубов.
После того как ты открыл cmd, ты должен ввести команду pip install модуль сразу же. А не после того, как написал команду python. Потому что команда python запускает интерактивный режим интерпретатора Python. И теперь все что ты пишешь — уже относится не к cmd, а Python коду.
В этом была твоя начальная ошибка.
>>> это приглашение интерепратора Python, а не cmd. Отсюда и ошибка invalid syntax, которая никакого отношения в PATH и cmd не имеет. Учи матчасть.
Ну а далее — методом тыка ты нашел файл pip, открыл cmd в каталоге Scripts и ввел команду. Это — правильно. Но описал все это ты неправильно, чем вводишь в заблуждение других.
P.S. Python нужно было сразу ставить с добавлением его в PATH (для этого есть специальная галочка при установке). Тогда нет необходимости переходить в каталог Scripts для запуска pip.
Python pip install invalid syntax Solution
The pip package installer must be run from the command line. If you try to install a package from the Python interpreter or in a Python program, you’ll encounter the SyntaxError: invalid syntax error.
In this guide, we’re going to discuss the cause of the pip install invalid syntax error and what it means. We’ll walk through an example of this error so you can learn how to fix it in your code.
Find your bootcamp match
Select Your Interest
Your experience
Time to start
GET MATCHED
By continuing you agree to our Terms of Service and Privacy Policy, and you consent to receive offers and opportunities from Career Karma by telephone, text message, and email.
By continuing you agree to our Terms of Service and Privacy Policy, and you consent to receive offers and opportunities from Career Karma by telephone, text message, and email.
pip install invalid syntax
Python pip is a package installer. The pip tool lets you download and install packages from the Python Package Index, where thousands of libraries are available with which you can work in your code.
The pip tool runs as its own command line interface. pip is separate from your installation of Python. This is because pip is an installer rather than a tool that executes code.
If these tools were bundled together, it would be more confusing for developers who want to install packages because similar syntax used to start a Python program would also apply to installing modules.
This behavior is common across programming environments. Node.js relies on npm to install packages. To run a program using Node.js, you need to use the node command.
An Example Scenario
We’re going to set up the Beautiful Soup 4 library (bs4) in a development environment. This library lets you scrape a web page and retrieve particular pieces of data.
To start, let’s open up a Python 3 shell. In this shell, we’ll do all the work for our project:
An interactive shell is opened in which we can write our Python code:
Python 3.8.5 (v3.8.5:580fbb018f, Jul 20 2020, 12:11:27) [Clang 6.0 (clang-600.0.57)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>>
Next, let’s import the bs4 library into our code. We must import any external libraries that we want to use before we can reference them in a program or the shell. Here’s the command we’ll use to import the bs4package:
>>> from bs4 import BeautifulSoup Traceback (most recent call last): File "", line 1, in ModuleNotFoundError: No module named 'bs4'
Our code returns a ModuleNotFoundError when we try to import our package. This means that we can’t continue writing our program. Python cannot locate the package modules that we need to write our program. Let’s fix this error by installing the bs4 library:
>>> pip install bs4
This command results in another error:
File "", line 1 pip3 install bs4 ^ SyntaxError: invalid syntax
It appears as if we cannot install bs4 using the pip3 command in the Python shell. pip3 is the package installer for Python 3 packages.
The Solution
We’ve tried to install the bs4 package from the Python interpreter.
You can tell because we’ve opened Python 3 using the python3 command and then we’ve executed the pip3 install command.
Python returns a pip install invalid syntax error because pip is not a keyword in Python. pip is a command line tool that must be run from a command line shell.
To fix this error, we must first exit our Python shell:
The exit() command tells Python to close the interpreter that is open. Next, we can install bs4 from the command prompt:
pip3 install bs4
This command will install the pip library onto our system. Once this command has executed, we can open up a new Python shell:
Our new shell should have access to the bs4 library. We can test this by importing bs4 into our code:
>>> from bs4 import BeautifulSoup >>>
No error is raised. This means that the import was successful. We can now use bs4 in our program.
Conclusion
The pip install invalid syntax error is raised when you try to install a Python package from the interpreter. To fix this error, exit your interpreter and run the pip install command from a command line shell.

«Career Karma entered my life when I needed it most and quickly helped me match with a bootcamp. Two months after graduating, I found my dream job that aligned with my values and goals in life!»
Venus, Software Engineer at Rockbot
Find Your Bootcamp Match
Now you have the expertise you need to solve this error like a professional coder!
About us: Career Karma is a platform designed to help job seekers find, research, and connect with job training programs to advance their careers. Learn about the CK publication.
What’s Next?
![]()
Want to take action?
Get matched with top bootcamps
![]()
Want to dive deeper?
Ask a question to our community
![]()
Want to explore tech careers?
Take our careers quiz

About the Author
Technical Content Manager at Career Karma
James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tuto. read more
Share This
Oct 5, 2020 —>
Leave a Reply Cancel reply

Apply to top tech training programs in one click
Get Matched
Related Articles


© 2023 Career Karma
Best Coding Bootcamps
Best Online Bootcamps
Best Web Design Bootcamps
Best Data Science Bootcamps
Best Data Analytics Bootcamps
Best Cyber Security Bootcamps
Best ISA Bootcamps 2020
Comparisons
Flatiron School vs Fullstack Academy
Hack Reactor vs App Academy
Fullstack Academy vs Hack Reactor
Thinkful vs General Assembly
Flatiron School vs Thinkful
General Assembly vs Flatiron School
App Academy vs Lambda School
General Assembly vs Hack Reactor
Springboard vs Thinkful
San Francisco Bootcamps
New York Bootcamps
Los Angeles Bootcamps
Chicago Bootcamps
Seattle Bootcamps
Atlanta Bootcamps
Austin Bootcamps
Coding Temple
Flatiron School
General Assembly
Springboard
Hack Reactor
App Academy
Software Engineering
UX/UI Design
Data Science
Web Development
Mobile Development
Cybersecurity
Product Management
JavaScript
At Career Karma, our mission is to empower users to make confident decisions by providing a trustworthy and free directory of bootcamps and career resources. We believe in transparency and want to ensure that our users are aware of how we generate revenue to support our platform.
Career Karma recieves compensation from our bootcamp partners who are thoroughly vetted before being featured on our website. This commission is reinvested into growing the community to provide coaching at zero cost to their members.
It is important to note that our partnership agreements have no influence on our reviews, recommendations, or the rankings of the programs and services we feature. We remain committed to delivering objective and unbiased information to our users.
In our bootcamp directory, reviews are purely user-generated, based on the experiences and feedback shared by individuals who have attended the bootcamps. We believe that user-generated reviews offer valuable insights and diverse perspectives, helping our users make informed decisions about their educational and career journeys.
Find the right bootcamp for you
By continuing you agree to our Terms of Service and Privacy Policy, and you consent to receive offers and opportunities from Career Karma by telephone, text message, and email.


Find a top-rated training program