0

I'm trying to install matplotlib but keep getting the error

Fatal error in launcher: Unable to create process using '"c:\users\sharjeel jan\appdata\local\programs\python\python36-32\python.exe" "C:\Users\Sharjeel Jan\AppData\Local\Programs\Python\Python36-32\Scripts\pip.exe" install matplotlib'

To fix this I've tried uninstalling and reinstalling python as well as pip. I've also tried to change the paths by following a bunch of tutorials.

So far I am certain that the path I am using is correct as I used this code to obtain it although the error remains:

import os
import sys
print(os.path.dirname(sys.executable))

If anyone could please help, that would be greatly appreciated!

pfx
  • 20,323
  • 43
  • 37
  • 57
YouKnowMe
  • 45
  • 1
  • 7
  • Possible duplicate of [Fatal error in launcher: Unable to create process using ""C:\Program Files (x86)\Python33\python.exe" "C:\Program Files (x86)\Python33\pip.exe""](https://stackoverflow.com/questions/24627525/fatal-error-in-launcher-unable-to-create-process-using-c-program-files-x86) – phd Aug 31 '18 at 22:18
  • https://stackoverflow.com/search?q=%5Bpip%5D+Fatal+error+in+launcher%3A+Unable+to+create+process+using+python.exe – phd Aug 31 '18 at 22:18
  • I suspect the problem is space in your user name "sharjeel jan". – phd Aug 31 '18 at 22:19

1 Answers1

1

This is a nice way for python to install packages using pip. This will make it so you don't need to worry about paths. It looks like pip is in your local system so do this by the following.

create a python script called "package_installer.py":

import pip
import sys
import subprocess

def install(package):
    subprocess.call([sys.executable, "-m", "pip", "install", package])

#example install itertools
install('itertools')

Then run the code, with the install in the script calling anything you'd like to install.

d_kennetz
  • 5,219
  • 5
  • 21
  • 44
  • thanks it worked but i still get an error in my python program saying; `File "C:\Users\Sharjeel Jan\Desktop\Projects\Data Analysis\Data Analysis Project.py", line 6, in import matplotlib.pylot as plt ModuleNotFoundError: No module named 'matplotlib.pylot'` what for be the reason for this error? – YouKnowMe Aug 31 '18 at 21:35
  • try `from matplotlib import pyplot as plt` – d_kennetz Aug 31 '18 at 21:36