Python

Python
Install
Packages
How to install and upgrade Python pip
Author

Marcelo Rosales

Published

March 27, 2023

Install python

I first try:

pip install --upgrade

ERROR: You must give at least one requirement to install (see "pip help install")

[notice] A new release of pip available: 22.2.1 -> 23.0.1
[notice] To update, run: python3.9 -m pip install --upgrade pip

# Then I tried
brew install python3

Displayed: Warning: No available formula with the name “python3.”.
Did you mean python@3.9, python@3.8, python@3.7, python@3.11 or python@3.10?
==> Searching for similarly named formulae and casks…
==> Formulae boost-python3 python@3.10 ✔ python@3.11 python@3.7 python@3.8 python@3.9 ✔

Install python with brew

brew install python@3.8 
# Or version needed

However, this install all version of python.
==> python@3.10 Python has been installed as /usr/local/bin/python3.10

Unversioned and major-versioned symlinks python, python3, python-config, python3-config, pip, pip3, etc. pointing to python3.10, python3.10-config, pip3.10 etc., respectively, have been installed into:
/usr/local/opt/python@3.10/libexec/bin

You can install Python packages with
pip3.10 install <package>
They will install into the site-package directory:
/usr/local/lib/python3.10/site-packages

tkinter is no longer included with this formula, but it is available separately:
brew install python-tk\@3.10

If you do not need a specific version of Python, and always want Homebrew’s python3 in your PATH:

  brew install python3

See: https://docs.brew.sh/Homebrew-and-Python

Warning: python@3.11 3.11.2_1 is already installed and up-to-date.

python3.9 -m pip install –upgrade pip
pip install –upgrade pip
python –version
>_Python 3.8.10

pip3 --vesrion

A Single Command to Run Python 3

For some of you reading this, this command may be enough. You can run Python 3 using this command (with the 3 at the end).

python3

To exit python help window press ++Cnt+z++

To print, press . To open an existing new project, press .

How to Install Pip on Mac

link

Pip is a package management system used for installing and managing Python software packages and libraries. The software and libraries are stored in a repository called the Python Package Index (PyPI).

Prerequisites:

  • A system running macOS
  • Python installed
  • A user account with administrator-level privileges

Install Pip on macOS via brew

To install pip on macOS through Homebrew. Make sure you have Homebrew installed by running the following command:

brew install python

The command installs the latest Python, pip, and setuptools.

Install Pip on macOS via get-pip.py

Follow the steps below to install Pip:

1. Press Command + Space Bar and type in Terminal. Click the app icon to open a new terminal window.
2. Check your Python version to make sure Python3 is installed: python3 --version
3. Download pip by running the following command: curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
The curl command allows you to specify a direct download link. Use the -o option to set the name of the downloaded file.
4. Install the downloaded package by running: python3 get-pip.py
5. Verify Pip Installation: pip --version

python3 --version
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3 get-pip.py
pip --version

Install pyenv to Manage Python Versions

link

Run this command:

brew install pyenv

How to Use pyenv to Install Python or Update Your Python Version

Now you just need to run the following command: pyenv install {# of the py version to install}

pyenv install 3.9.2

Set Python to Local or Global

link

If you only want to use Python 3.x for a specific project, then cd to your specific directory and type:

pyenv local 3.x.x

If you’d prefer to just have Python 3.x installed globally throughout your operating system, then type:

pyenv global 3.x.x

Install Jupiter

brew install jupyter
# Start Jupyter
jupyter notebook

Summary

Terminal

pip3 --version
brew install python3 
brew install python #same as above
brew install pyenv
brew install jupyter
pip install --upgrade pip
python3.11 -m pip install --upgrade pip

pip install numpy
pip install matplotlib   #Still asking for numpy

# This code made it work...
pip3 install numpy
pip3 install matplotlib

# Optional commands to make python run in RStudio:
python3 -m pip install numpy
python3.11 -m pip install --upgrade pip
pip3.10 install numpy
python3.10 -m pip install --upgrade pip

Errors and Troubleshooting

Warning

In background Jobs:

Error: ModuleNotFoundError: No module named ‘numpy’ Execution halted

Solution
pip3 install numpy
pip3 install matplotlib