Fatal error in launcher: Unable to create process using pip

avatar
Borislav Hadzhiev

Last updated: Apr 10, 2024
5 min

banner

# Fatal error in launcher: Unable to create process using pip

The Python "Fatal error in launcher: Unable to create process using pip" occurs for multiple reasons:

  1. Not having the path to pip in your user's PATH environment variable.
  2. Not having pip installed on your machine.
  3. Having a corrupted Python installation.
  4. Having an outdated version of pip.
shell
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.

cmd
python -m pip install requests py -m pip install requests python3 -m pip install requests

use python m executable

Using the Python executable python -m pip instead of pip directly works even if the path to pip isn't set in your PATH environment variable.

# Upgrade your version of pip

If that didn't help, try upgrading your version of pip.

main.py
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.

Even if using python -m works as a quick fix, it's still recommended to add pip and Python to your PATH environment variable.

# Add the path to Python and pip to your user's PATH environment variable

To add the path to Python and pip to your user's PATH environment variable:

  1. Click on the Search bar and type "environment variables".
  2. Click on "Edit the system environment variables".

edit system environment variables

  1. Click on the "Environment Variables" button.

click environment variables

  1. In the "User variables for YOUR_USER" section, select the "Path" variable and click "Edit".

select user path click edit

  1. Click on "New" and then click "Browse".

click new browse

  1. You can use one of the following commands to check where your Python installation is located.
cmd
python -c "import os, sys; print(os.path.dirname(sys.executable))" where python

find python path

For me, the path is the following.

cmd
C:\Users\YOUR_USER\AppData\Local\Programs\Python\Python310

Note that I have Python 3.10 installed, which is reflected in the PATH.

  1. 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.

cmd
C:\Users\YOUR_USER\AppData\Local\Programs\Python\Python310\Scripts

add scripts folder

  1. Once the two paths are added, confirm the changes by clicking on the "OK" button twice.

added python and pip to path

  1. Close your Command prompt application and reopen it.
Note that you must restart your Command prompt application for the changes to take effect.

You might also have to restart your PC, but that's not always necessary.

cmd
pip --version pip install numpy

using pip commands

Assuming you restarted Command Prompt, if the error persists, try to use the official installer to set up Python correctly.

# Adding Python and pip to your PATH using the official installer

If you still encounter issues, try to add Python to your PATH using the official installer.

  1. Download the installer from the official python.org website.

  2. If you have Python already installed, start the installer and click on "Modify".

click modify

You can leave the optional features ticked. Note that the pip checkbox is checked.

optional features

  1. On the "Advanced Options" screen, make sure to tick the "Add Python to environment variables" option.

add python to environment variables

  1. Once the "Add Python to environment variables" checkbox is checked, click "Install".
Now your Python installation should be set up correctly and Python should be added to your user's PATH environment variable.

If that didn't work, your Python installation might be corrupted. You can use the official installer to reinstall Python.

# Reinstall Python using the official installer

  1. Start the installer again and click on "Uninstall".

uninstall python

  1. Once Python is removed successfully, start the installer again and tick the "Add python.exe to PATH" option.

add python exe to path

  1. The "Add python.exe to PATH" option won't be checked by default.

  2. Once the "Add python.exe to PATH" checkbox is checked, click on "Install Now".

After the installation, Python should be installed and configured properly.

Close and reopen all active Command Prompt shells before issuing any pip commands.
cmd
pip --version pip install numpy

using pip commands

If the error is not resolved, try to run the following command to install pip.

cmd
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:

  1. Clicking on the link.
  2. Right-clicking and selecting "Save as" in your browser.

Open your shell in the location where the get-pip.py file is downloaded and run the following command.

cmd
python get-pip.py py get-pip.py python3 get-pip.py

The get-pip.py script uses bootstrapping logic to install pip.

# Try to install the package from within a Python script

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.

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.

Make sure to replace requests with the name of the module you're trying to install.

# Installing a requirements.txt file from within a Python script

Here is an example that installs a requirements.txt file from within a Python script named main.py.

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.

# Conclusion

To solve the "Fatal error in launcher: Unable to create process using pip", make sure:

  1. You have the path to Python and pip in your user's PATH environment variable.
  2. You have pip and Python installed on your machine.
  3. Your pip version is up to date.
I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.