Question: Blender comes with Python, and includes a stand-alone Python executable.
However pip is not part of the official Python distribution so it needs to be added separately.

* How do you setup `pip` with Blender's bundled Python so it can be used to install Python packages from [Pypi](https://pypi.org/) which are then available from inside Blender?
* How would you use it to install a package?

---

Note, this is related to [this question](https://blender.stackexchange.com/questions/14489/), but not a duplicate since its not about using pip as a library.

Answer: 
Since PIP is included with Blender from ~2.8 onward you can install things via pip directly from the Blender scripting workspace eg

```
#For Blender 2.92:
#You have to have admininistor priviledges so for Windows users
#JUST THIS ONCE open Blender by R-clicking on it in the start menu and select"Run as Administrator"

#Open up the System Console (under the Window menu)
#Then paste and run the following into the scripting workspace and run it
# After it has run, then close and reopen Blender normally
# You can then then use the module as normal with 
# import MODULE

#--- FROM HERE ---#

import subprocess
import sys
import os

# path to python.exe
python_exe = os.path.join(sys.prefix, 'bin', 'python.exe')

# upgrade pip
subprocess.call([python_exe, "-m", "ensurepip"])
subprocess.call([python_exe, "-m", "pip", "install", "--upgrade", "pip"])

# install required packages
subprocess.call([python_exe, "-m", "pip", "install", "PACKAGE_TO_INSTALL"])

print("DONE")

```

However, if you use **Windows 10**, the python interpreter installs new packages not into the Blender installation directory, but into the personal user directory. We can solve the problem by hard-coding the directory where pip should install the required packages – the *site-packages* directory located inside the directory where *Blender* is installed.

```
target = os.path.join(sys.prefix, 'lib', 'site-packages')

```

Windows 10 script:

```
import subprocess
import sys
import os

python_exe = os.path.join(sys.prefix, 'bin', 'python.exe')
target = os.path.join(sys.prefix, 'lib', 'site-packages')

subprocess.call([python_exe, '-m', 'ensurepip'])
subprocess.call([python_exe, '-m', 'pip', 'install', '--upgrade', 'pip'])

#example package to install (SciPy):
subprocess.call([python_exe, '-m', 'pip', 'install', '--upgrade', 'scipy', '-t', target])

print('DONE')

```

More info available [here](https://b3d.interplanety.org/en/installing-python-packages-with-pip-in-blender-on-windows-10/)
First make sure your Blender *System Console* is open by clicking menu *Window > Toggle System Console* so you can see installation progress.

[![enter image description here](https://i.stack.imgur.com/uu4HW.png)](https://i.stack.imgur.com/uu4HW.png)

Go to *Scripting Tab* and run the following script. It simply gets the path to your current `python_exe` file and installs the [`ensurepip`](https://pip.pypa.io/en/stable/installation/#ensurepip) module, which can install *pip* in a Python environment. `pip` is simply a thing that can install python packages such as [NumPy](https://numpy.org/).

```
import subprocess
import sys
import os

python_exe = os.path.join(sys.prefix, 'bin', 'python.exe')

subprocess.call([python_exe, '-m', 'ensurepip'])
subprocess.call([python_exe, '-m', 'pip', 'install', '--upgrade', 'pip'])

```

This can take a while, so check your console to see the progress. Once pip has been successfully installed, you can run this script to install any python package. In this example I install the [SciPy](https://www.w3schools.com/python/scipy/scipy_intro.php) library package:

```
import subprocess
import sys
import os

python_exe = os.path.join(sys.prefix, 'bin', 'python.exe')
subprocess.call([python_exe, '-m', 'pip', 'install', '--upgrade', 'scipy'])

```

[![enter image description here](https://i.stack.imgur.com/52vh9.png)](https://i.stack.imgur.com/52vh9.png)

Replace *scipy* with any other library or package you need to install.