11

This is a really annoying problem. I've prowled the web for solutions, but all I found was tips about changing the PATH variable, which I did, of course. My Python install directory is C:\Python27. It' a 32 bit version. Whenever I type python in the command prompt, it says that it isn't recognised as an internal or external command. Currently, my PATH variable is set to C:\Python27;C:\Python27\Lib\site-packages\;C:\Python27\Scripts. Anyone has any ideas? I run Windows 7 by the way (64 bit). I'm pretty desperate. Heck, if nothing works I guess I'll try dual-booting Linux and Windows 7...

Ohm
  • 133
  • 1
  • 1
  • 9
  • Download the 64 bit version. – Volatility Mar 02 '13 at 05:38
  • It's alright. happened with me to too. Restart the machine and check again :) – Keval Domadia Mar 02 '13 at 05:39
  • There are advantages to 32bit python. Memory management prevents writing to pagefile and the memory allocation of objects is a lot more efficient. – Octipi Mar 02 '13 at 05:41
  • I read that the 64-bit version doesn't support lots of modules (I really dont want to miss out) but I guess I'll give it a try if a 2nd restart doesn't settle it. – Ohm Mar 02 '13 at 05:44
  • 1
    @Ohmnivore: Check [this site](http://www.lfd.uci.edu/~gohlke/pythonlibs/) for unofficial 64bit versions of python libraries. It was linked to from the numpy webpage. – Octipi Mar 02 '13 at 05:46
  • 2
    Did you re-open your cmd prompt after installing it? – Cianan Sims Mar 02 '13 at 05:50
  • 2
    @user2125950: This seems obvious but I thought I would ask. Did you close your window after adding the path? My memory tells me that you have to click apply and actually close the window. – Octipi Mar 02 '13 at 05:51
  • Uhm I restarted and nothing changed... Also, I did close the window. However, there's something that's bugging me. It doesn't ask for "apply". That button is grayed out and I end up clicking twice "OK" instead of OK, then apply, then OK. Just noticed it. I suspect it might have something to do with the problem. Maybe the variables aren't changing correctly... – Ohm Mar 02 '13 at 06:01
  • Actually I'm not sure if you need to click apply. It is greyed out on my machine too. – Octipi Mar 02 '13 at 06:03
  • Type `set path` on the command prompt and verify that `C:\Python27` is correctly added to it. – Mark Tolonen Mar 02 '13 at 06:10
  • It is correctly added. – Ohm Mar 02 '13 at 06:13
  • Try `python.exe` instead of just `python`. Also is `c:\python27` the first or last thing in the path? A previous component of the path could be bad, such as a space in the wrong place. – Mark Tolonen Mar 02 '13 at 06:14
  • 2
    @Ohmnivore, enter _PATH=C:\Python27_ on the command line. Then try running python. That gets rid of everything in your path except python. Its a good sanity check. If python runs, your PATH statement wasn't what you thought it was. – tdelaney Mar 02 '13 at 06:21
  • Finally! I've found the culprit! After some meticulous verification of PATH I've stumbled upon a Processing install directory that had a C"\ instead of C:\. I'm fairly sure no one had added that path manually, so... yeah... screw you Processing! – Ohm Mar 02 '13 at 06:50
  • Thanks tdelaney. Unfortunately there' no way I can mark your comment as an answer :( – Ohm Mar 02 '13 at 06:52

8 Answers8

31

Just adding the Python path and trying again worked for me (without reboot).

MS-dos command for Python 2.7:

set PATH=%PATH%;C:\python27\

MS-dos command for Python 3.3:

set PATH=%PATH%;C:\python33\

(check if that is the folder where you installed Python).

Timothée HENRY
  • 14,294
  • 21
  • 96
  • 136
  • the only solution that worked for me. editing PATH in the pesky GUI did nothing including after system and cmd reboots. – brucezepplin Jul 20 '17 at 08:22
4

Quick fix: May not be the most elegant or long term fix but if you are really frustrated and just want to get it to run, just copy paste the python.exe file to your current directory. This worked for me.

user1210233
  • 2,730
  • 5
  • 24
  • 31
  • Woah that's awesome. Maybe not elegant, but a hell of a quick fix! Thanks, it worked perfectly! – Ohm Mar 02 '13 at 06:07
1

After changing the PATH variable in windows, you need to reboot your system before it takes effect.

Edit: As stated by @tdelaney, only a restart of cmd.exe should be required. This is true atleast for Windows 7 64bit.

Oddstr13
  • 201
  • 1
  • 7
  • @Oddstr13, you don't need to reboot - the setting applies to all new command windows. Just exit your command prompt and start another one. – tdelaney Mar 02 '13 at 06:18
1

After adding the python folder to the system PATH variable, you should reboot your computer.

Another simple solution is: create a shortcut of the python.exe executable (probably it is in C:\Python27\python.exe, or similar) in a place like C:\Windows\system32 (that is, a place that already is listed in the PATH variable). The name of your shortcut should be python (maybe python.exe should work too). I mean, it can't be python - shortcut or similar, for your purposes.

To see the contents of the PATH variable, go to the cmd and enter set PATH.

thiagowfx
  • 4,832
  • 6
  • 37
  • 51
  • I did reboot a couple of times, but I think the shortcut method is gonna fix it. C:\Python27 is in PATH, that's what puzzled me in the first place. Thanks a lot! – Ohm Mar 02 '13 at 06:09
  • Unfortunately the shortcut doesn't work. A copy of python.exe works, but not the shortcut, despite two attemps: one where it was named python and another where it was named python.exe. – Ohm Mar 02 '13 at 06:14
  • @Ohmnivore I tried here. I downloaded python from http://www.python.org/ftp/python/2.7.3/python-2.7.3.msi . My Windows 7 is 64-bit also, but the installation was okay. Unfortunately, I couldn't add the Python shortcut to any folder listed because Windows didn't let me do it (said I don't have permissions lol).But I managed to add `;C:\Python27` to the end of the **PATH** variable. It worked instantly. Did you substituted or appended the Python path in the **PATH** variable? It shouldn't be only `PATH=C:\Python27`; you should maintain the previous paths there. – thiagowfx Mar 03 '13 at 15:54
0

In your PATH have you got a leading space before your Python path?

For example:

"C:\somedirectory\bin; C:\Python27;C:\Python27\Lib\site-packages\;C:\Python27\Scripts"

If you have a leading space between path's "ry\bin; C:\Pyt", it won't work and is usually the cause for this type of issue.

corvuscorax
  • 5,850
  • 3
  • 30
  • 31
Matt Conway
  • 229
  • 2
  • 8
0

When installing, there is a checkbox that is by default not selected, but it asks to add python to the environment variable. Re-install and check that box.

I'd rather the installer do it than struggle in the weeds myself.

drneel
  • 2,887
  • 5
  • 30
  • 48
Osbad44
  • 1
  • 1
0

Okay, as you said your Python install directory is C:\Python27, open my computer, then open c: drive, if you don't see "Python27" named folder there then try to search it using search option, (in my case i found it in old.window folder, don't know how it moved there) cut and past it in c drive along with folders like, program files, user etc... , now open cmd and type python and hit enter to check if it is working now,

Bhanu
  • 1
  • 1
0

This is only a partial answer, but I found (repeatedly) that I'd have similar issues when I would use the gui installer and not go through the custom setup.

Using the custom setup option, then using the same settings, the "install for all users" (that then installs to C://python.version/blah instead of the user based default structure) WOULD allow the installer to setup PATH correctly.

jeff porter
  • 6,560
  • 13
  • 65
  • 123