Python Forum
Using pip correctly in Windows and Mac
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using pip correctly in Windows and Mac
#1
Hello Forum,
I would like to see if anyone could confirm which command prompt instructions are correct as far as using pip when installing modules or packages. I am Windows user but often have access to a Mac.

Windows
Check if Python is installed: python --version
If pip is not installed: python -m ensurepip --default-pip
To update pip: python -m pip install -U pip
To install module and package: either pip install <module_name> OR python -m pip install <module_name> (what is the difference?)

Mac or Linux
Check if Python is installed: python3 --version (why python3 instead of just python?)
If pip is not installed: sudo easy_install pip
To update pip: pip install -U pip
To install modules and packages: either pip install <module-name> OR python -m pip install <module_name>

Thanks!
Reply
#2
(Feb-19-2021, 01:31 PM)bytecrunch Wrote: (why python3 instead of just python?)
For compatibility reasons python will point to the old python 2 executable.
On systems where you use python3 you will most likely have to use pip3 instead of pip.
bytecrunch likes this post
Reply
#3
(Feb-19-2021, 02:44 PM)ibreeden Wrote:
(Feb-19-2021, 01:31 PM)bytecrunch Wrote: (why python3 instead of just python?)
For compatibility reasons python will point to the old python 2 executable.
On systems where you use python3 you will most likely have to use pip3 instead of pip.

Thanks Ibreeden.

Do the other commands look ok and consistent with what you are using?
Reply
#4
For Windows.
Python 3.9/3.8 and pip installation under Windows

(Feb-19-2021, 01:31 PM)bytecrunch Wrote: To update pip: python -m pip install -U pip
Ok.

(Feb-19-2021, 01:31 PM)bytecrunch Wrote: To install module and package: either pip install <module_name> OR python -m pip install <module_name> (what is the difference?)
The -m option allows you to execute a module or package as a script.
If pip is set in OS Path as it should be,then it's just more typing for same task.
G:\
λ python -m pip -V
pip 20.2.4 from C:\python39\lib\site-packages\pip (python 3.9)

G:\
λ pip -V
pip 20.2.4 from c:\python39\lib\site-packages\pip (python 3.9)
(Feb-19-2021, 01:31 PM)bytecrunch Wrote: Mac or Linux
The right and wrong way to set Python 3 as default on a Mac
Alternative for both Linux and Mac.
pyenv Simple Python Version Management.
Reply
#5
(Feb-19-2021, 10:46 PM)bytecrunch Wrote:
(Feb-19-2021, 02:44 PM)ibreeden Wrote: For compatibility reasons python will point to the old python 2 executable.
On systems where you use python3 you will most likely have to use pip3 instead of pip.

Thanks Ibreeden.

Do the other commands look ok and consistent with what you are using?
On many linux systems where linux2 is default you can install "python-is-python3" which makes python3 the default.
Others use "alias python=python3" to get python3 as the default.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020