Last updated: Apr 10, 2024
Reading time·5 min
The Python "Fatal error in launcher: Unable to create process using pip" occurs for multiple reasons:
pip
in your user's PATH environment variable.pip
installed on your machine.pip
.Fatal error in launcher: Unable to create process using "C:\Program Files (x86)\Python311\python.exe" "C:\Program Files (x86)\Python311\pip.exe"
One way to get around the error is to use the python -m pip
command instead of
using pip
directly.
python -m pip install requests py -m pip install requests python3 -m pip install requests
python -m pip
instead of pip
directly works even if the path to pip
isn't set in your PATH environment variable.If that didn't help, try upgrading your version of pip.
python -m ensurepip --upgrade python -m pip install --upgrade pip py -m ensurepip --upgrade py -m pip install --upgrade pip python3 -m ensurepip --upgrade python3 -m pip install --upgrade pip
The ensurepip
package enables us to bootstrap the pip
installer into an
existing Python installation or virtual environment.
python -m
works as a quick fix, it's still recommended to add pip
and Python to your PATH environment variable.pip
to your user's PATH environment variableTo add the path to Python and pip
to your user's PATH environment
variable:
python -c "import os, sys; print(os.path.dirname(sys.executable))" where python
For me, the path is the following.
C:\Users\YOUR_USER\AppData\Local\Programs\Python\Python310
Note that I have Python 3.10 installed, which is reflected in the PATH.
Add the path to Python and then add the path to the Scripts
directory that
is located in your Python3X folder.
This is where the executable files are located, including pip.exe
.
For me, it is the following path.
C:\Users\YOUR_USER\AppData\Local\Programs\Python\Python310\Scripts
You might also have to restart your PC, but that's not always necessary.
pip --version pip install numpy
Assuming you restarted Command Prompt, if the error persists, try to use the official installer to set up Python correctly.
pip
to your PATH using the official installerIf you still encounter issues, try to add Python to your PATH using the official installer.
Download the installer from the official python.org website.
If you have Python already installed, start the installer and click on "Modify".
You can leave the optional features ticked. Note that the pip
checkbox is
checked.
If that didn't work, your Python installation might be corrupted. You can use the official installer to reinstall Python.
The "Add python.exe to PATH" option won't be checked by default.
Once the "Add python.exe to PATH" checkbox is checked, click on "Install Now".
After the installation, Python should be installed and configured properly.
pip
commands.pip --version pip install numpy
If the error is not resolved, try to run the following command to install pip
.
python -m ensurepip --upgrade py -m ensurepip --upgrade python3 -m ensurepip --upgrade
Alternatively, you can use the official get-pip script to install pip.
Download the script from https://bootstrap.pypa.io/get-pip.py by:
Open your shell in the location where the get-pip.py
file is downloaded and
run the following command.
python get-pip.py py get-pip.py python3 get-pip.py
The get-pip.py
script uses bootstrapping logic to install pip
.
Another thing you can try is to install the package from within a Python script.
Here is an example of installing the requests
package from within a Python
script named main.py
.
import sys import subprocess python = sys.executable subprocess.check_call( [python, '-m', 'pip', 'install', 'requests'] )
You can run the file with python main.py
, python3 main.py
or py main.py
to
install the requests
module.
requests
with the name of the module you're trying to install.Here is an example that installs a
requirements.txt file
from within a Python script named main.py
.
import sys import subprocess requirements_file = open('requirements.txt', 'r', encoding='utf-8') packages = requirements_file.read().splitlines() print(packages) python = sys.executable for package in packages: subprocess.check_call( [python, '-m', 'pip', 'install', package], )
The code sample assumes that you have a requirements.txt
file located in the
same directory as your Python script.
You can run the file with python main.py
, python3 main.py
or py main.py
to
install the modules in your requirements.txt
file.
To solve the "Fatal error in launcher: Unable to create process using pip", make sure:
pip
in your user's PATH environment
variable.pip
and Python installed on your machine.pip
version is up to date.