First make sure your Blender System Console is open by clicking menu Window > Toggle System Console so you can see installation progress.
Go to Scripting Tab and run the following script. It simply gets the path to your current python_exe
file and installs the ensurepip
module, which can install pip in a Python environment. pip
is simply a thing that can install python packages such as NumPy.
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 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'])
Replace scipy with any other library or package you need to install.