1

I have the familiar problem of not being able to install a Python package, pyautogui; "syntax invalid", with install highlighted:

pip install pyautogui

The explanations I've read are all the same, that this code is to be entered into one of the IDLE windows and not the other. Well I've tried both and the result is the same, syntax invalid.

This is Python 3.4.3 on Windows 7.

Erik Vesterlund
  • 440
  • 5
  • 16

1 Answers1

2

As @TigerhawkT3 said in the comments, you are supposed to install from CMD, not the Python Shell. pip is an executable that downloads packages.

As the wikipedia page on pip states:

One major advantage of pip is the ease of its command-line interface, which makes installing Python software packages as easy as issuing one command

So pip needs to be run from the command line.

So how do you use pip?

Since you are on Windows 7 the sure-fire way to run it is to open the start menu, type cmd, and click the first result. Then you will be running command prompt, or CMD for short. I suggest that you run pip -h to display the help for more on how to use pip.

If you have

'pip' is not recognized as an internal or external command, operable program or batch file.

You need to add the path to your scripts folder (the solution is this SO question).

To take an excerpt, you need to execute

setx PATH "%PATH%;C:\Python34\Scripts".

Note that you need to close and re-open CMD for the change to take effect.

Good luck!

EDIT:

For future reference, if you want to set the environment variable, and Setx isn't working, you should search for Edit the system environment variables. Then go to Environment Variables->(in the second list) Path. Then double click that, and append C:\Python34\Scripts;.

IronManMark20
  • 1,228
  • 11
  • 26
  • Thanks! Actually setx... didn't do the trick, this did: set PATH=%PATH%;C:\Python34\Scripts The setx stuff yielded the following (freely translated): "Warning! The saved data is truncated to 1024 digits. EXECUTED: The stated value has been saved." After this, the output from echo %PATH% was still unchanged. But your answer qualifies as The answer anyway, so thanks! – Erik Vesterlund Jun 27 '15 at 01:30
  • No problem. That is a strange error, I have not seen it before. I will edit to give the possibly better way of doing it. (Doing it through the set a system environment variable.) – IronManMark20 Jun 27 '15 at 03:41